pass rest of args through
This commit is contained in:
parent
5fde67110e
commit
bace327634
2 changed files with 9 additions and 6 deletions
|
|
@ -148,6 +148,7 @@ aliases:
|
|||
{"gh co", []string{"pr", "checkout"}, ""},
|
||||
{"gh il", nil, `not enough arguments for alias: issue list --author="$1" --label="$2"`},
|
||||
{"gh il vilmibm", nil, `not enough arguments for alias: issue list --author="vilmibm" --label="$2"`},
|
||||
{"gh co 123", []string{"pr", "checkout", "123"}, ""},
|
||||
{"gh il vilmibm epic", []string{"issue", "list", `--author=vilmibm`, `--label=epic`}, ""},
|
||||
{"gh pr status", []string{"pr", "status"}, ""},
|
||||
{"gh dne", []string{"dne"}, ""},
|
||||
|
|
|
|||
|
|
@ -483,13 +483,15 @@ func ExpandAlias(args []string) ([]string, error) {
|
|||
|
||||
if aliases.Exists(args[1]) {
|
||||
expansion := aliases.Get(args[1])
|
||||
for i, a := range args[2:] {
|
||||
if !strings.Contains(expansion, "$") {
|
||||
expansion += " " + a
|
||||
} else {
|
||||
expansion = strings.ReplaceAll(expansion, fmt.Sprintf("$%d", i+1), a)
|
||||
}
|
||||
}
|
||||
if strings.Contains(expansion, "$") {
|
||||
for i, a := range args[2:] {
|
||||
expansion = strings.Replace(expansion, fmt.Sprintf("$%d", i+1), a, 1)
|
||||
}
|
||||
if strings.Contains(expansion, "$") {
|
||||
return empty, fmt.Errorf("not enough arguments for alias: %s", expansion)
|
||||
}
|
||||
return empty, fmt.Errorf("not enough arguments for alias: %s", expansion)
|
||||
}
|
||||
return shlex.Split(expansion)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue