grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
Add support for specifying which mercurial executable to use
14 months ago, Gary Kramlich
8275959b76f0
Add support for specifying which mercurial executable to use
package
hg
import
(
"github.com/alecthomas/kong"
"github.com/kballard/go-shellquote"
)
type
CommandArguments
struct
{
Hg
struct
{
Repo
string
`kong:"flag,short='R'"`
Serve
struct
{
Stdio
bool
`kong:"flag,name='stdio'"`
}
`kong:"cmd"`
Init
struct
{
Repo
string
`kong:"arg"`
}
`kong:"cmd"`
}
`kong:"cmd"`
}
func
ParseCommandArguments
(
cmd
string
)
(
string
,
CommandArguments
,
error
)
{
values
:=
CommandArguments
{}
args
,
err
:=
shellquote
.
Split
(
cmd
)
if
err
!=
nil
{
return
""
,
values
,
err
}
parser
:=
kong
.
Must
(
&
values
)
ctx
,
err
:=
parser
.
Parse
(
args
)
if
err
!=
nil
{
return
""
,
values
,
err
}
return
ctx
.
Command
(),
values
,
nil
}