goombaio / cli Goto Github PK
View Code? Open in Web Editor NEWA flag parse library with support for commands and subcommands.
License: Apache License 2.0
A flag parse library with support for commands and subcommands.
License: Apache License 2.0
Is your feature request related to a problem? Please describe.
Added support for LongDescription in commands
If a flag is provided but not defined command should fail:
$ program -f
Error: unknown flag: -f
Usage()
$ program -foo
Error: unknown flag: -foo
Usage()
Is your feature request related to a problem? Please describe.
Reach gold criteria on CI best practices badge.
Describe the solution you'd like
https://bestpractices.coreinfrastructure.org/en/projects/2177?criteria_level=2
Deprecate long flags with only one dash:
-h, -help Show help message -----> should be --help
There is an example failing at examples/simple:
./simple_withoutconstructor -h
or ./simple_withoutconstructor -help
doesn't work.
Is your feature request related to a problem? Please describe.
Add support to build commands without a constructor.
So I want to create a command like this:
var RootCommand = &cli.Command{
Name: "programName",
ShortDescription: "rootCommand Description",
LongDescription: "rootCommand Long Description",
Run: func(c *cli.Command) error {
c.Usage()
return nil
},
}
err := RootCommand.Execute()
if err != nil {
_ = RootCommand.Logger().Log("ERROR:", err)
}
This now is not working and produces the following stacktrace:
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x112f879]
goroutine 6 [running]:
testing.tRunner.func1(0xc00009e200)
/usr/local/go/src/testing/testing.go:792 +0x387
panic(0x1179fc0, 0x12e0190)
/usr/local/go/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc0000b5d60)
/usr/local/go/src/text/template/exec.go:160 +0x1d0
panic(0x1179fc0, 0x12e0190)
/usr/local/go/src/runtime/panic.go:513 +0x1b9
text/template.(*state).walk(0xc0000b5ce0, 0x118cc20, 0xc0000cc000, 0x99, 0x11d1a80, 0xc00000e4e0)
/usr/local/go/src/text/template/exec.go:269 +0x3b9
text/template.(*state).walk(0xc0000b5ce0, 0x118cc20, 0xc0000cc000, 0x99, 0x11d18c0, 0xc00000e4b0)
/usr/local/go/src/text/template/exec.go:262 +0x142
text/template.(*Template).execute(0xc00004a780, 0x0, 0x0, 0x118cc20, 0xc0000cc000, 0x0, 0x0)
/usr/local/go/src/text/template/exec.go:217 +0x215
text/template.(*Template).Execute(0xc00004a780, 0x0, 0x0, 0x118cc20, 0xc0000cc000, 0x0, 0x1)
/usr/local/go/src/text/template/exec.go:200 +0x53
github.com/goombaio/cli.(*Command).Usage(0xc0000a80a0)
/Users/raul/Projects/goombaio/cli/usage.go:88 +0x493
github.com/goombaio/cli_test.TestCommand_withoutConstructor.func1(0xc0000a80a0, 0x0, 0x0)
/Users/raul/Projects/goombaio/cli/command_test.go:49 +0x2b
github.com/goombaio/cli.(*Command).Execute(0xc0000a80a0, 0xc0000a80a0, 0x5baa565a)
/Users/raul/Projects/goombaio/cli/command.go:204 +0xf2
github.com/goombaio/cli_test.TestCommand_withoutConstructor(0xc00009e200)
/Users/raul/Projects/goombaio/cli/command_test.go:55 +0x10a
testing.tRunner(0xc00009e200, 0x11b1530)
/usr/local/go/src/testing/testing.go:827 +0xbf
created by testing.(*T).Run
/usr/local/go/src/testing/testing.go:878 +0x353
FAIL github.com/goombaio/cli 0.014s
? github.com/goombaio/cli/examples/simple [no test files]
? github.com/goombaio/cli/examples/simple_command [no test files]
make: *** [test] Error 1
Add support to ignore the long flag
For example I would like to define a flag -v but --verbose should not work.
Also in the Usage must be reflected like this:
-h, -help Show help message
-v Verbose mode enabled
-force Force an operation
Is your feature request related to a problem? Please describe.
Reach passing criteria on CI best practices badge.
Describe the solution you'd like
https://bestpractices.coreinfrastructure.org/en/projects/2177
Right now:
$ program -f # works
$ program -force # works
$ program --force # doesn't work
Describe the bug
Using help flag do not show the correct usage:
$ goomba -h
Usage of goomba:
$ goomba -help
Usage of goomba:
For example I would like to define a flag --force but -f should not work.
Also in the Usage must be reflected like this:
-h, --help Show help message
--force Force an operation
Is your feature request related to a problem? Please describe.
Reach silver criteria on CI best practices badge.
Describe the solution you'd like
https://bestpractices.coreinfrastructure.org/en/projects/2177?criteria_level=1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.