working on messaging library, adding branching options to client
This commit is contained in:
@@ -2,6 +2,9 @@ version = "0.1.5"
|
||||
rootPath = ""
|
||||
currentbranch = "master"
|
||||
|
||||
localbranches = ["master"]
|
||||
remotebranches = ["master", "test", "test2"]
|
||||
|
||||
[[remote]]
|
||||
name = "test2"
|
||||
host = "localhost"
|
||||
|
Binary file not shown.
@@ -1,7 +1,6 @@
|
||||
package clientcmd
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
@@ -10,7 +9,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
clientconfig "github.com/deranjer/gvc/client/clientconfig"
|
||||
"github.com/deranjer/gvc/messages"
|
||||
messages "github.com/deranjer/gvc/messages"
|
||||
)
|
||||
|
||||
// ConfigPath is the global path to the config that is injected from the main client package.
|
||||
@@ -76,25 +75,28 @@ func ConnectToServer(serverName string, branchName string, conf *clientconfig.Gv
|
||||
port := ":" + strconv.Itoa(remote.Port)
|
||||
connectionString := remote.Host + port
|
||||
conn, err := net.Dial("tcp", connectionString)
|
||||
defer conn.Close()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error connecting to %s", connectionString)
|
||||
}
|
||||
fmt.Println("Attempting connection on: ", connectionString)
|
||||
decoder := json.NewDecoder(conn)
|
||||
newMessage := messages.Cmd{}
|
||||
var newMessage messages.Command
|
||||
for { // Doing our 'handshake'
|
||||
decoder.Decode(&newMessage)
|
||||
|
||||
message, err := bufio.NewReader(conn).ReadString('\n')
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading from connection: %s", err)
|
||||
}
|
||||
fmt.Printf("Message from server: %s", message)
|
||||
switch message {
|
||||
case "Connected\n":
|
||||
fmt.Println("Message from server", newMessage)
|
||||
switch newMessage.CmdID {
|
||||
case messages.CONNECTED:
|
||||
fmt.Println("Server recognized client")
|
||||
return &conn, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected response from server: ", message)
|
||||
fmt.Println("message: ", newMessage.CmdID)
|
||||
return nil, fmt.Errorf("Unexpected message from server")
|
||||
//return nil, fmt.Errorf("unexpected response from server: ", newMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,12 +2,14 @@ package config
|
||||
|
||||
//Gvcconfig will be the struct that holds the entire client settings
|
||||
type Gvcconfig struct {
|
||||
Version string `toml:"version"`
|
||||
RootPath string `toml:"rootPath"`
|
||||
CurrentBranch string `toml:"currentbranch"`
|
||||
Remotes []Remote `toml:"remote"` //The remote servers for the repo
|
||||
Ignores Ignore `toml:"ignore"` //These files will be ignored for all add functions
|
||||
NoCompress Ignore `toml:"nocompress"` //For binary compression some files should be ignored because the performance hit isn't worth the size savings
|
||||
Version string `toml:"version"`
|
||||
RootPath string `toml:"rootPath"`
|
||||
CurrentBranch string `toml:"currentbranch"`
|
||||
LocalBranches []string `toml:"localbranches"` // LocalBranches constains a string list of branches on the local client. Names must be unique. \\TODO: someday add folders like git for branches
|
||||
RemoteBranches []string `toml:"remotebranches"` // RemoteBranches constains a string list of branches on the server. Names must be unique. \\TODO: someday add folders like git for branches
|
||||
Remotes []Remote `toml:"remote"` //The remote servers for the repo
|
||||
Ignores Ignore `toml:"ignore"` //These files will be ignored for all add functions
|
||||
NoCompress Ignore `toml:"nocompress"` //For binary compression some files should be ignored because the performance hit isn't worth the size savings
|
||||
}
|
||||
|
||||
//Remote will be a slice of remote server information
|
||||
|
@@ -1,12 +0,0 @@
|
||||
module github.com/deranjer/gvc/client
|
||||
|
||||
go 1.14
|
||||
|
||||
replace derajnet.duckdns.org/git/deranjer/gvc => ../gvc //alias for local development
|
||||
|
||||
replace github.com/deranjer/gvc => ../gvc
|
||||
|
||||
require (
|
||||
github.com/deranjer/clir v1.0.5
|
||||
github.com/deranjer/store v0.0.0-20200526205429-464dd59c6031
|
||||
)
|
@@ -1,12 +0,0 @@
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/deranjer/clir v1.0.5 h1:tEunZj5qJLYNBtzMQ/vH8hEAIv4NptWFmTldsP9U2qY=
|
||||
github.com/deranjer/clir v1.0.5/go.mod h1:x/FAjr5CHGsBT0yjs+NYxX3qFxx8G15gbeCcN6FFuyU=
|
||||
github.com/deranjer/store v0.0.0-20200526205429-464dd59c6031 h1:sPjxPMNILoBbu6uhDfa97AhlUhTgtPY2HqySAzuLd4o=
|
||||
github.com/deranjer/store v0.0.0-20200526205429-464dd59c6031/go.mod h1:wPOs9IJ77lRTXyjEOQeegCFjIlm21qOFcv33lXmU7gE=
|
||||
github.com/mailru/easyjson v0.7.1 h1:mdxE1MF9o53iCb2Ghj1VfWvh7ZOwHpnVG/xwXrV90U8=
|
||||
github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
Reference in New Issue
Block a user