Compare commits
No commits in common. "v1.0.0-rc.2" and "main" have entirely different histories.
v1.0.0-rc.
...
main
@ -53,9 +53,9 @@ By default, and unless ﹅` + env.NoColor + `﹅ is set, ﹅@chinampa@ help﹅ w
|
||||
if len(args) > 0 && c != nil && c.Name() != args[len(args)-1] {
|
||||
c, topicArgs, err := c.Root().Find(args)
|
||||
if err == nil && c != nil && len(topicArgs) == 0 {
|
||||
// user requestd command help with flag command
|
||||
// exact command help
|
||||
cobra.CheckErr(c.Help())
|
||||
os.Exit(statuscode.Ok)
|
||||
os.Exit(statuscode.RenderHelp)
|
||||
return
|
||||
}
|
||||
|
||||
@ -74,12 +74,9 @@ By default, and unless ﹅` + env.NoColor + `﹅ is set, ﹅@chinampa@ help﹅ w
|
||||
os.Exit(statuscode.NotFound)
|
||||
}
|
||||
|
||||
// top-level help with no arguments called
|
||||
// write to stdout
|
||||
c.SetOut(os.Stdout)
|
||||
c.InitDefaultHelpFlag() // make possible 'help' flag to be shown
|
||||
cobra.CheckErr(c.Help())
|
||||
|
||||
os.Exit(statuscode.Ok)
|
||||
os.Exit(statuscode.RenderHelp)
|
||||
},
|
||||
}
|
||||
|
@ -182,11 +182,6 @@ func (arg *Argument) SetValue(value []string) {
|
||||
arg.provided = &value
|
||||
}
|
||||
|
||||
// Repeats tells if an argument should be presented as a list.
|
||||
func (arg *Argument) Repeats() bool {
|
||||
return arg.Variadic
|
||||
}
|
||||
|
||||
func (arg *Argument) IsKnown() bool {
|
||||
return arg.provided != nil && len(*arg.provided) > 0
|
||||
}
|
||||
|
@ -137,11 +137,6 @@ func (opt *Option) ToString() string {
|
||||
return stringValue
|
||||
}
|
||||
|
||||
// Repeats tells if an option should be presented as a list.
|
||||
func (opt *Option) Repeats() bool {
|
||||
return opt.Repeated
|
||||
}
|
||||
|
||||
func (opt *Option) internalValidate(name, current string) error {
|
||||
if current == "" {
|
||||
return nil
|
||||
|
@ -25,8 +25,12 @@ func showHelp(cmd *cobra.Command) {
|
||||
// HandleCobraExit is called when a command errors out or was not found.
|
||||
func HandleCobraExit(cmd *cobra.Command, err error) error {
|
||||
if err == nil {
|
||||
ok, err := cmd.PersistentFlags().GetBool(_c.HelpCommandName)
|
||||
if cmd.Name() == _c.HelpCommandName || err == nil && ok {
|
||||
os.Exit(statuscode.RenderHelp)
|
||||
}
|
||||
|
||||
os.Exit(statuscode.Ok)
|
||||
return nil
|
||||
}
|
||||
|
||||
switch err.(type) {
|
||||
|
@ -4,7 +4,6 @@ package logger
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"git.rob.mx/nidito/chinampa/pkg/runtime"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -48,10 +47,6 @@ func Configure(name string, level Level) {
|
||||
}
|
||||
}
|
||||
|
||||
func SetOutput(out io.Writer) {
|
||||
logrus.SetOutput(out)
|
||||
}
|
||||
|
||||
func Debug(args ...any) {
|
||||
Main.Debug(args...)
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ package statuscode
|
||||
const (
|
||||
// Ok means everything is fine.
|
||||
Ok = 0
|
||||
// RenderHelp provides answers to life, the universe and everything; also, renders help.
|
||||
RenderHelp = 42
|
||||
// Usage means bad arguments were provided by the user.
|
||||
Usage = 64
|
||||
// ProgrammerError means the developer made a mistake.
|
||||
|
Loading…
x
Reference in New Issue
Block a user