only process aliases when non-existent command passed
This commit is contained in:
parent
db741a0284
commit
2627c5bb74
2 changed files with 13 additions and 5 deletions
|
|
@ -32,10 +32,18 @@ func main() {
|
|||
|
||||
stderr := utils.NewColorable(os.Stderr)
|
||||
|
||||
expandedArgs, err := command.ExpandAlias(os.Args)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "failed to process aliases: %s\n", err)
|
||||
os.Exit(2)
|
||||
expandedArgs := []string{}
|
||||
if len(os.Args) > 0 {
|
||||
expandedArgs = os.Args[1:]
|
||||
}
|
||||
|
||||
cmd, _, err := command.RootCmd.Traverse(expandedArgs)
|
||||
if err != nil || cmd == command.RootCmd {
|
||||
expandedArgs, err = command.ExpandAlias(os.Args)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "failed to process aliases: %s\n", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
}
|
||||
|
||||
command.RootCmd.SetArgs(expandedArgs)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
// TODO
|
||||
// - [ ] DEBUG support
|
||||
// - [ ] give our commands precedence
|
||||
// - [x] give our commands precedence
|
||||
// - [x] prevent overriding existing gh command
|
||||
// - [x] allow overwriting alias
|
||||
// - [x] forward extra arguments
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue