-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add viper bindpflags in cmd config (#48)
* feat: add viper bindpflags in config * fix: lint and run go fmt * fix: config and cmdx * feat: add loader opts to Load function * fix(cmdx): recursion on hook * refactor(cmdx): pass pflags instead of cmd to WithBindFlags Co-authored-by: Ravi Suhag <[email protected]>
- Loading branch information
Showing
6 changed files
with
83 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package cmdx | ||
|
||
import "github.com/spf13/cobra" | ||
|
||
// SetClientHook applies custom cobra config specific | ||
// for client or cmd that have annotation `client:true` | ||
func SetClientHook(rootCmd *cobra.Command, applyFunc func(cmd *cobra.Command)) { | ||
for _, subCmd := range rootCmd.Commands() { | ||
if subCmd.Annotations != nil && subCmd.Annotations["client"] == "true" { | ||
applyFunc(subCmd) | ||
} | ||
SetClientHook(subCmd, applyFunc) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,3 +105,7 @@ func ErrorIcon() { | |
func InfoIcon() { | ||
fmt.Print(term.Cyan("⛭")) | ||
} | ||
|
||
func Space() { | ||
fmt.Print(" ") | ||
} |