-
Notifications
You must be signed in to change notification settings - Fork 157
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
Rewrite CLI: nknc and nknd #857
Conversation
1e63b23
to
39a7704
Compare
cmd/nknd/commands/root.go
Outdated
timer.Reset(30 * time.Minute) | ||
break |
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.
break
should be changed to continue
since you removed select
cmd/nknd/commands/portmapper.go
Outdated
@@ -1,4 +1,4 @@ | |||
package main | |||
package cmd |
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.
We follow the convention to match package name with directory name. Since the directory name is commands
, the package name should also be commands
. Same for 'root.go
I think it's better to submit the changes for nknc in the same PR so we can remove the dependency of |
pushed nknc cli. fixed review. |
squashed. |
With the new structure, all commands (e.g. |
yeah I already moved all shared vars to so, as I understand it, you want me to make all vars global? |
This is exactly what I'm thinking as well, but there are a few variables that are used in more than one files but not defined in |
ok. I will check everything and commit soon. |
done |
57100ac
to
02bbe3e
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
rebased |
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.
LGTM
Upon further review it seems that print version feature is missing. Previously |
is what I get. |
Yep that's what I meant by missing because it's always 1.0... The expected behavior is to print version set in Makefile, to be more specific, it should be git tag and commit hash. You should pass version when creating cobra.Command (to |
|
For now they are the same, but as you can see they might contain different build parameters in the future, so it's better to keep both
|
Switch from urfave/cli to spf13/cobra. Same functionality, just different cli library, resulting in less loc. Signed-off-by: omani <3346207+omani@users.noreply.github.com>
pls review the change. I kept the version flag for |
Looks good to me! |
Proposed changes in this pull request
Switch from urfave/cli to spf13/cobra. Same functionality, just different cli library, resulting in less loc.
Additionally, minor changes in code to fix a few warnings by compiler.
Type (put an
x
where ever applicable)Extra information
cobra will have a new release around June 2022 with new features like
MarkFlagsRequiredTogether()
andMarkFlagsMutuallyExclusive()
which will reduce the loc even further, since we won't have to check for set flags manually anymore.Im planning to implement them once cobra releases v1.5.0.