Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ce84a374cc | |||
| 6842224b37 |
@@ -1,5 +1,5 @@
|
||||
# go-cli
|
||||
|
||||
[](https://pkg.go.dev/git.tebibyte.media/sashakoshka/cli)
|
||||
[](https://pkg.go.dev/git.tebibyte.media/sashakoshka/go-cli)
|
||||
|
||||
CLI module for Go programs.
|
||||
|
||||
6
cli.go
6
cli.go
@@ -169,7 +169,8 @@ func (this *Cli) ParseOrExit (args []string) *Cli {
|
||||
// was found, it returns true. If it was not found, it returns nil, false.
|
||||
func (this *Cli) ShortFlag (short rune) (*Flag, bool) {
|
||||
if short == 0 { return nil, false }
|
||||
for _, flag := range this.Flags {
|
||||
for index := len(this.Flags) - 1; index >= 0; index -- {
|
||||
flag := this.Flags[index]
|
||||
if flag.Short == short { return flag, true }
|
||||
}
|
||||
return nil, false
|
||||
@@ -179,7 +180,8 @@ func (this *Cli) ShortFlag (short rune) (*Flag, bool) {
|
||||
// was found, it returns true. If it was not found, it returns nil, false.
|
||||
func (this *Cli) LongFlag (long string) (*Flag, bool) {
|
||||
if long == "" { return nil, false }
|
||||
for _, flag := range this.Flags {
|
||||
for index := len(this.Flags) - 1; index >= 0; index -- {
|
||||
flag := this.Flags[index]
|
||||
if flag.Long == long { return flag, true }
|
||||
}
|
||||
return nil, false
|
||||
|
||||
Reference in New Issue
Block a user