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
MYST-688 Start having subcommands of "mysterium_node" #316
Conversation
d0ea62b
to
05d6d1f
Compare
cmd/network.go
Outdated
@@ -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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No error can be returned from the function, we can remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
cmd/network.go
Outdated
}, | ||
cli.BoolFlag{ | ||
Name: "localnet", | ||
Usage: "Defines network configuration which expects localy deployed broker and discovery services", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: locally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
cmd/commands/application/command.go
Outdated
if err := cmd.RegisterDirectoryFlags(&app.Flags, &options); err != nil { | ||
return app, err | ||
} | ||
app.Flags = append(app.Flags, tequilapiAddressFlag, tequilapiPortFlag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd moved this append after the if
block, to make it more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved flag registration
cmd/commands/license/command_test.go
Outdated
|
||
import ( | ||
"testing" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpicking: extra spaces in imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
cmd/commands/version/command_test.go
Outdated
|
||
import ( | ||
"testing" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpicking: extra spaces in imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
cmd/directories.go
Outdated
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*
for flags
can be omitted here, slice already a reference type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried, but did not succeed pass wo reference sign &
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I tried, but in that cases, values is appended to copies :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, got it. Sorry for confusing.
@@ -19,20 +19,25 @@ package main | |||
|
|||
import ( | |||
"fmt" | |||
"os" | |||
"path/filepath" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpicking: extra spaces in imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
core/node/options.go
Outdated
package node | ||
|
||
// NodeOptions describes options which are required to start Command | ||
type NodeOptions struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type name will be used as node.NodeOptions by other packages, and that stutters; consider calling this Options (golint)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
cmd/commands/application/command.go
Outdated
app.Copyright = licenseCopyright | ||
|
||
if err := cmd.RegisterDirectoryFlags(&app.Flags, &options); err != nil { | ||
return app, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed to return nil, err
@@ -30,7 +30,8 @@ const seewayLogXmlConfig = ` | |||
</seelog> | |||
` | |||
|
|||
func init() { | |||
// Bootstrap loads seelog package into the overall system | |||
func Bootstrap() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Longer is very angry of such hack then you include package with _
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That practice is allowed only in tests.go
or main.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I see. In that case - let's Bootstrap instead of init
All in all - nice 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address @soffokl comments too
05d6d1f
to
c6b6094
Compare
cmd/commands/application/command.go
Outdated
return err | ||
} | ||
|
||
*flags = append(*flags, tequilapiAddressFlag, tequilapiPortFlag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I want to keep specific order of flags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, clear
cmd/commands/application/command.go
Outdated
return app, nil | ||
} | ||
|
||
func registerFlags(flags *[]cli.Flag) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, take a look on comment here.
ae62894
to
4eee4b0
Compare
4eee4b0
to
298d167
Compare
298d167
to
c028b32
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Output of
bin/build && bin/run --help