Silence usage on commands that apply
This commit is contained in:
1 parent
6436253629
commit
da81e6ccd9
3 files changed
+9
No files matched your search
@@ -48,6 +48,10 @@ func commandInit() *cobra.Command {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flags and arguments are valid from here on, so errors are runtime
|
||||||
|
// failures: report them without cobra's usage text.
|
||||||
|
cmd.SilenceUsage = true
|
||||||
|
|
||||||
cfgFile, _ := cmd.Flags().GetString("config")
|
cfgFile, _ := cmd.Flags().GetString("config")
|
||||||
if cfgFile != "" {
|
if cfgFile != "" {
|
||||||
// Use config file from the flag.
|
// Use config file from the flag.
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ func (o *Options) Bind(cmd *cobra.Command) {
|
|||||||
func (o *Options) RunSetup(
|
func (o *Options) RunSetup(
|
||||||
cmd *cobra.Command, loadConfig bool, terminalLog bool,
|
cmd *cobra.Command, loadConfig bool, terminalLog bool,
|
||||||
) (*config.JobSearchConfig, error) {
|
) (*config.JobSearchConfig, error) {
|
||||||
|
// Flags and arguments are valid from here on, so errors are runtime
|
||||||
|
// failures: report them without cobra's usage text.
|
||||||
|
cmd.SilenceUsage = true
|
||||||
|
|
||||||
// Check for debug level or quiet supression via args
|
// Check for debug level or quiet supression via args
|
||||||
conf := &config.JobSearchConfig{
|
conf := &config.JobSearchConfig{
|
||||||
Logging: config.JobSearchConfigLogging{},
|
Logging: config.JobSearchConfigLogging{},
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ func NewCommand() *cobra.Command {
|
|||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "version",
|
Use: "version",
|
||||||
Short: "Print version information",
|
Short: "Print version information",
|
||||||
|
SilenceUsage: true,
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
slog.Debug("version.PersistentPreRun")
|
slog.Debug("version.PersistentPreRun")
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user