Skip to content

Commit

Permalink
set flags as mutually exclusive with cobra
Browse files Browse the repository at this point in the history
  • Loading branch information
0pcom committed Jun 22, 2023
1 parent ceb1b90 commit b482716
Show file tree
Hide file tree
Showing 16 changed files with 262 additions and 176 deletions.
11 changes: 3 additions & 8 deletions cmd/skywire-cli/commands/config/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ func init() {
homepath := visorconfig.HomePath()
if homepath != "" {
genConfigCmd.Flags().BoolVarP(&isUsrEnv, "user", "u", false, "use paths for user space: "+homepath+"\033[0m")
genConfigCmd.MarkFlagsMutuallyExclusive("pkg", "user")
}

genConfigCmd.Flags().BoolVarP(&isRegen, "regen", "r", false, "re-generate existing config & retain keys")
genConfigCmd.MarkFlagsMutuallyExclusive("regen", "force")
genConfigCmd.Flags().VarP(&sk, "sk", "s", "a random key is generated if unspecified\n\r")
gHiddenFlags = append(gHiddenFlags, "sk")
genConfigCmd.Flags().BoolVarP(&isTestEnv, "testenv", "t", false, "use test deployment "+testConf+"\033[0m")
Expand Down Expand Up @@ -179,14 +182,6 @@ var genConfigCmd = &cobra.Command{
if isStdout {
isRegen = false
}
//--force will delete a config, which excludes --regen
if (isForce) && (isRegen) {
log.Fatal("Use of mutually exclusive flags: -f --force cannot override -r --regen")
}
// these flags overwrite each other
if (isUsrEnv) && (isPkgEnv) {
log.Fatal("Use of mutually exclusive flags: -u --user and -p --pkg")
}
//enable local hypervisor by default for user
if isUsrEnv {
isHypervisor = true
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/skycoin/skycoin v0.27.1
github.com/skycoin/yamux v0.0.0-20200803175205-571ceb89da9f
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
github.com/spf13/cobra v1.4.0
github.com/spf13/cobra v1.5.0
github.com/stretchr/testify v1.8.3
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 // indirect
Expand Down
4 changes: 3 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.15 h1:cKRCLMj3Ddm54bKSpemfQ8AtYFBhAI2MPmdys22fBdc=
github.com/creack/pty v1.1.15/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
Expand Down Expand Up @@ -580,8 +581,9 @@ github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY52
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4=
github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q=
github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
Expand Down
51 changes: 0 additions & 51 deletions vendor/github.com/spf13/cobra/CHANGELOG.md

This file was deleted.

6 changes: 3 additions & 3 deletions vendor/github.com/spf13/cobra/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions vendor/github.com/spf13/cobra/bash_completions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b482716

Please sign in to comment.