diff --git a/commands/args.go b/commands/args.go index 5b7dc95cd49638fd3c340659ec7b0b0f2df5b510..81a4ae8ebac5effcc4ce6972a96f00f8aee49829 100644 --- a/commands/args.go +++ b/commands/args.go @@ -106,6 +106,10 @@ func (a *Args) IsParamsEmpty() bool { return a.ParamsSize() == 0 } +func (a *Args) PrependParams(params ...string) { + a.Params = append(params, a.Params...) +} + func (a *Args) AppendParams(params ...string) { a.Params = append(a.Params, params...) } diff --git a/commands/runner.go b/commands/runner.go index 33e7e88d0595c3d32601b7a5fe40c2488ac858c0..7da223884ae7f87edcdcea55584a5c8e39c44ec6 100644 --- a/commands/runner.go +++ b/commands/runner.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/jingweno/gh/cmd" "github.com/jingweno/gh/git" + shellquote "github.com/kballard/go-shellquote" ) type Runner struct { @@ -93,6 +94,10 @@ func expandAlias(args *Args) { cmd := args.Command expandedCmd, err := git.Config(fmt.Sprintf("alias.%s", cmd)) if err == nil && expandedCmd != "" { - args.Command = expandedCmd + words, err := shellquote.Split(expandedCmd) + if err != nil { + args.Command = words[0] + args.PrependParams(words[1:]...) + } } }