diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-01-13 17:42:15 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-01-14 09:46:55 +0300 |
commit | edf1138908964a65b4676121b99cf7a627aa612a (patch) | |
tree | 8930e8caf3d2c26449353bfeaa385199987530b6 | |
parent | e5c3c07f5d71da404813cc5b9db86fd75efbcc47 (diff) |
git: Document public symbols
This commit documents some of the global functions exposed in order to
implement options.
-rw-r--r-- | internal/git/command.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/git/command.go b/internal/git/command.go index 18ee25eca..cb98ba4b5 100644 --- a/internal/git/command.go +++ b/internal/git/command.go @@ -138,10 +138,14 @@ type SubSubCmd struct { PostSepArgs []string } +// Subcommand returns the name of the given git command which this SubSubCmd +// executes. E.g. for `git remote add`, it would return "remote". func (sc SubSubCmd) Subcommand() string { return sc.Name } var actionRegex = regexp.MustCompile(`^[[:alnum:]]+[-[:alnum:]]*$`) +// CommandArgs checks all arguments in the SubSubCommand and validates them, +// returning the array of all arguments required to execute it. func (sc SubSubCmd) CommandArgs() ([]string, error) { var safeArgs []string @@ -212,6 +216,8 @@ type Flag struct { Name string } +// GlobalArgs returns the arguments for the given flag, which should typically +// only be the flag itself. It returns an error if the flag is not sanitary. func (f Flag) GlobalArgs() ([]string, error) { return f.OptionArgs() } @@ -231,6 +237,8 @@ type ValueFlag struct { Value string } +// GlobalArgs returns the arguments for the given value flag, which should +// typically be two arguments: the flag and its value. It returns an error if the value flag is not sanitary. func (vf ValueFlag) GlobalArgs() ([]string, error) { return vf.OptionArgs() } |