This commit is contained in:
Jingwen Owen Ou 2013-08-16 07:16:59 -07:00
Родитель b756e1dc5f
Коммит 1eb87b822b
2 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -106,6 +106,10 @@ func (a *Args) IsParamsEmpty() bool {
return a.ParamsSize() == 0 return a.ParamsSize() == 0
} }
func (a *Args) PrependParams(params ...string) {
a.Params = append(params, a.Params...)
}
func (a *Args) AppendParams(params ...string) { func (a *Args) AppendParams(params ...string) {
a.Params = append(a.Params, params...) a.Params = append(a.Params, params...)
} }

Просмотреть файл

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"github.com/jingweno/gh/cmd" "github.com/jingweno/gh/cmd"
"github.com/jingweno/gh/git" "github.com/jingweno/gh/git"
shellquote "github.com/kballard/go-shellquote"
) )
type Runner struct { type Runner struct {
@ -93,6 +94,10 @@ func expandAlias(args *Args) {
cmd := args.Command cmd := args.Command
expandedCmd, err := git.Config(fmt.Sprintf("alias.%s", cmd)) expandedCmd, err := git.Config(fmt.Sprintf("alias.%s", cmd))
if err == nil && expandedCmd != "" { if err == nil && expandedCmd != "" {
args.Command = expandedCmd words, err := shellquote.Split(expandedCmd)
if err != nil {
args.Command = words[0]
args.PrependParams(words[1:]...)
}
} }
} }