Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MYST-688 Start having subcommands of "mysterium_node" #316

Merged

Conversation

Projects
None yet
3 participants
@Waldz
Copy link
Member

commented Aug 23, 2018

Output of bin/build && bin/run --help

NAME:
   mysterium_node - VPN server and client for Mysterium Network https://mysterium.network/

USAGE:
   mysterium_node [global options] command [command options] [arguments...]

VERSION:
   source.dev-build

AUTHOR:
   The "MysteriumNetwork/node" Authors <mysterium-dev@mysterium.network>

COMMANDS:
     version  Show version
     license  Show license
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --data-dir value                 Data directory containing keystore & other persistent files (default: "/Users/waldz/.mysterium")
   --config-dir value               Configs directory containing all configuration, script and helper files (default: "/Users/waldz/workspace/go/src/github.com/mysterium/node/build/node/config")
   --runtime-dir value              Runtime writable directory for temp files (default: "/Users/waldz/workspace/go/src/github.com/mysterium/node/build/node")
   --tequilapi.address value        IP address of interface to listen for incoming connections (default: "127.0.0.1")
   --tequilapi.port value           Port for listening incoming api requests (default: 4050)
   --testnet                        Defines test network configuration
   --localnet                       Defines network configuration which expects localy deployed broker and discovery services
   --discovery-address value        Address (URL form) of discovery service (default: "https://testnet-api.mysterium.network/v1")
   --broker-address value           Address (IP or domain name) of message broker (default: "testnet-broker.mysterium.network")
   --ether.client.rpc value         Url or IPC socket to connect to ethereum node, anything what ethereum client accepts - works (default: "https://ropsten.infura.io")
   --ether.contract.payments value  Address of payments contract (default: "0xbe5F9CCea12Df756bF4a5Baf4c29A10c3ee7C83B")
   --openvpn.binary value           openvpn binary to use for Open VPN connections (default: "openvpn")
   --ipify-url value                Address (URL form) of ipify service (default: "https://api.ipify.org/")
   --location.database value        Service location autodetect database of GeoLite2 format e.g. http://dev.maxmind.com/geoip/geoip2/geolite2/ (default: "GeoLite2-Country.mmdb")
   --cli                            Run an interactive CLI based Mysterium UI
   --help, -h                       show help
   --version, -v                    print the version

COPYRIGHT:
   Mysterium Node Copyright (C) 2017 The "MysteriumNetwork/node" Authors.
This program comes with ABSOLUTELY NO WARRANTY; for details run command 'license --warranty'.
This is free software, and you are welcome to redistribute it
under certain conditions; run command 'license --conditions' for details.

@Waldz Waldz requested a review from mysteriumnetwork/core Aug 23, 2018

@Waldz Waldz requested a review from tadovas as a code owner Aug 23, 2018

@Waldz Waldz changed the title MYST-688 Integrate cli subcommands tool MYST-688 Start having subcommands of executable Aug 23, 2018

@Waldz Waldz changed the title MYST-688 Start having subcommands of executable MYST-688 Start having subcommands of "mysterium_node" Aug 23, 2018

@Waldz Waldz force-pushed the Waldz:feature/MYST-688-executable-subcommands branch 2 times, most recently from d0ea62b to 05d6d1f Aug 23, 2018

@@ -109,3 +69,46 @@ func ParseNetworkOptions(flags *flag.FlagSet, options *NetworkOptions) {
"Address of payments contract",
)
}

// RegisterNetworkFlags function register directory options to flag set
func RegisterNetworkFlags(flags *[]cli.Flag, options *node.NodeOptions) error {

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 23, 2018

Member

No error can be returned from the function, we can remove it.

This comment has been minimized.

Copy link
@Waldz

Waldz Aug 23, 2018

Author Member

fixed

},
cli.BoolFlag{
Name: "localnet",
Usage: "Defines network configuration which expects localy deployed broker and discovery services",

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 23, 2018

Member

typo: locally

This comment has been minimized.

Copy link
@Waldz

Waldz Aug 23, 2018

Author Member

Fixed

if err := cmd.RegisterDirectoryFlags(&app.Flags, &options); err != nil {
return app, err
}
app.Flags = append(app.Flags, tequilapiAddressFlag, tequilapiPortFlag)

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 23, 2018

Member

I'd moved this append after the if block, to make it more readable.

This comment has been minimized.

Copy link
@Waldz

Waldz Aug 23, 2018

Author Member

Improved flag registration


import (
"testing"

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 23, 2018

Member

nitpicking: extra spaces in imports.

This comment has been minimized.

Copy link
@Waldz

Waldz Aug 23, 2018

Author Member

Fixed


import (
"testing"

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 23, 2018

Member

nitpicking: extra spaces in imports.

This comment has been minimized.

Copy link
@Waldz

Waldz Aug 23, 2018

Author Member

Fixed

func (options *DirectoryOptions) Check() error {
err := ensureDirExists(options.Config)
// RegisterDirectoryFlags function register directory options to flag set
func RegisterDirectoryFlags(flags *[]cli.Flag, options *node.NodeOptions) error {

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 23, 2018

Member

* for flags can be omitted here, slice already a reference type.

This comment has been minimized.

Copy link
@Waldz

Waldz Aug 23, 2018

Author Member

Tried, but did not succeed pass wo reference sign &

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 23, 2018

Member

just removing all & and * solves the problem.
like following:
image

This comment has been minimized.

Copy link
@Waldz

Waldz Aug 24, 2018

Author Member

Yes I tried, but in that cases, values is appended to copies :/

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 24, 2018

Member

OK, got it. Sorry for confusing.

@@ -19,20 +19,25 @@ package main

import (
"fmt"
"os"
"path/filepath"

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 23, 2018

Member

nitpicking: extra spaces in imports.

This comment has been minimized.

Copy link
@Waldz

Waldz Aug 23, 2018

Author Member

Fixed

package node

// NodeOptions describes options which are required to start Command
type NodeOptions struct {

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 23, 2018

Member

type name will be used as node.NodeOptions by other packages, and that stutters; consider calling this Options (golint)

This comment has been minimized.

Copy link
@Waldz

Waldz Aug 23, 2018

Author Member

Renamed

app.Copyright = licenseCopyright

if err := cmd.RegisterDirectoryFlags(&app.Flags, &options); err != nil {
return app, err

This comment has been minimized.

Copy link
@tadovas

tadovas Aug 23, 2018

Member

Is it intentional to return app object and not-nil error? Normal go convensions say that in case of error - returned object contains undefined state and should not be used (from caller perspective)

This comment has been minimized.

Copy link
@Waldz

Waldz Aug 23, 2018

Author Member

fixed to return nil, err

@@ -30,7 +30,8 @@ const seewayLogXmlConfig = `
</seelog>
`

func init() {
// Bootstrap loads seelog package into the overall system
func Bootstrap() {

This comment has been minimized.

Copy link
@tadovas

tadovas Aug 23, 2018

Member

why explicit Bootstrap calling is better when previous init() way? Init is guaranteed to be called only once per whole program. Bootstrap can be called in multiple places by different packages - and introduce very interesting side effects if not carefully used.

This comment has been minimized.

Copy link
@Waldz

Waldz Aug 23, 2018

Author Member

Longer is very angry of such hack then you include package with _

This comment has been minimized.

Copy link
@Waldz

Waldz Aug 23, 2018

Author Member

That practice is allowed only in tests.go or main.go

This comment has been minimized.

Copy link
@tadovas

tadovas Aug 23, 2018

Member

Ok I see. In that case - let's Bootstrap instead of init

@tadovas

This comment has been minimized.

Copy link
Member

commented Aug 23, 2018

All in all - nice 👍

@tadovas
Copy link
Member

left a comment

Please address @soffokl comments too

@Waldz Waldz force-pushed the Waldz:feature/MYST-688-executable-subcommands branch from 05d6d1f to c6b6094 Aug 23, 2018

return err
}

*flags = append(*flags, tequilapiAddressFlag, tequilapiPortFlag)

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 23, 2018

Member

I was talking about moving all appends together:

 	cmd.RegisterNetworkFlags(flags, &options)

	*flags = append(*flags, tequilapiAddressFlag, tequilapiPortFlag)
 	*flags = append(*flags, openvpnBinaryFlag, ipifyUrlFlag, locationDatabaseFlag)
	*flags = append(*flags, cliFlag)

This comment has been minimized.

Copy link
@Waldz

Waldz Aug 23, 2018

Author Member

But I want to keep specific order of flags

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 23, 2018

Member

oh, clear

return app, nil
}

func registerFlags(flags *[]cli.Flag) error {

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 23, 2018

Member

Please, take a look on comment here.

func (options *DirectoryOptions) Check() error {
err := ensureDirExists(options.Config)
// RegisterDirectoryFlags function register directory options to flag set
func RegisterDirectoryFlags(flags *[]cli.Flag, options *node.Options) error {

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 23, 2018

Member

Please, take a look on comment here.

@@ -109,3 +69,46 @@ func ParseNetworkOptions(flags *flag.FlagSet, options *NetworkOptions) {
"Address of payments contract",
)
}

// RegisterNetworkFlags function register directory options to flag set
func RegisterNetworkFlags(flags *[]cli.Flag, options *node.Options) {

This comment has been minimized.

Copy link
@soffokl

soffokl Aug 23, 2018

Member

Please, take a look on comment here.

@Waldz Waldz force-pushed the Waldz:feature/MYST-688-executable-subcommands branch 2 times, most recently from ae62894 to 4eee4b0 Aug 24, 2018

Waldz added some commits Aug 20, 2018

@Waldz Waldz force-pushed the Waldz:feature/MYST-688-executable-subcommands branch from 4eee4b0 to 298d167 Aug 28, 2018

Waldz added some commits Aug 23, 2018

@Waldz Waldz force-pushed the Waldz:feature/MYST-688-executable-subcommands branch from 298d167 to c028b32 Aug 28, 2018

@soffokl
Copy link
Member

left a comment

Looks good to me.

@Waldz Waldz merged commit de4a89a into mysteriumnetwork:master Aug 28, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Waldz Waldz deleted the Waldz:feature/MYST-688-executable-subcommands branch Aug 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.