Skip to content

Commit 4902633

Browse files
committed
CLI is up and running just needs to start making some RPC calls
1 parent e6e482e commit 4902633

File tree

8 files changed

+91
-20
lines changed

8 files changed

+91
-20
lines changed

main.go

Lines changed: 0 additions & 20 deletions
This file was deleted.
File renamed without changes.

src/cli-tool

2.25 MB
Binary file not shown.
File renamed without changes.

src/config/config.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) 2018 Clearmatics Technologies Ltd
2+
3+
package config
4+
5+
import (
6+
"encoding/json"
7+
"fmt"
8+
"io/ioutil"
9+
)
10+
11+
// Settings
12+
type Setup struct {
13+
Port_to string `json:"rpc-port-to"`
14+
Addr_to string `json:"rpc-addr-to"`
15+
Port_from string `json:"rpc-port-from"`
16+
Addr_from string `json:"rpc-addr-from"`
17+
}
18+
19+
func Read(config string) (setup Setup) {
20+
raw, err := ioutil.ReadFile(config)
21+
if err != nil {
22+
fmt.Print(err, "\n")
23+
}
24+
25+
err = json.Unmarshal(raw, &setup)
26+
27+
return setup
28+
}

src/config/config_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2018 Clearmatics Technologies Ltd
2+
3+
package config_test
4+
5+
import (
6+
"github.com/stretchr/testify/assert"
7+
"runtime"
8+
"strings"
9+
"testing"
10+
11+
"gitlab.clearmatics.net/dev/boe-poc/src/config"
12+
)
13+
14+
func Test_ParseParameters_ValidUserFile(t *testing.T) {
15+
path := findPath() + "../user.json"
16+
commandLine := []string{path}
17+
18+
setup := config.ParseParameters(commandLine)
19+
20+
assert.Equal(t, "http://rt-poc2-2.azurewebsites.net", setup.APIURL)
21+
assert.Equal(t, "password", setup.Grant_type)
22+
assert.Equal(t, "svcp93lXc&", setup.Password)
23+
assert.Equal(t, "user1@scheme1.co.uk", setup.User)
24+
}
25+
26+
func findPath() string {
27+
_, path, _, _ := runtime.Caller(0)
28+
pathSlice := strings.Split(path, "/")
29+
return strings.Trim(path, pathSlice[len(pathSlice)-1])
30+
}

src/main.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) 2018 Clearmatics Technologies Ltd
2+
3+
package main
4+
5+
import (
6+
"fmt"
7+
"os"
8+
"flag"
9+
10+
"github.com/validation/src/cli"
11+
"github.com/validation/src/config"
12+
)
13+
14+
var configFile = flag.String("config", "", "Description:\n path to the configuration file")
15+
16+
func main() {
17+
flag.Parse()
18+
19+
if *configFile != "" {
20+
setup := config.Read(*configFile)
21+
cli.Launch()
22+
} else {
23+
fmt.Print("Error: empty config!\n")
24+
os.Exit(3)
25+
}
26+
27+
}

src/setup.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"rpc-addr-to":"127.0.0.1",
3+
"rpc-port-to":8501,
4+
"rpc-addr-from":"127.0.0.1",
5+
"rpc-port-from":8502
6+
}

0 commit comments

Comments
 (0)