aboutsummaryrefslogtreecommitdiff
path: root/opts.go
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-11-30 01:06:57 +0100
committerThomas Voss <mail@thomasvoss.com> 2023-11-30 01:06:57 +0100
commitbc291f2bc1f256dc396b687c39bf8f349be016c3 (patch)
tree45476b3d19263a400f5ee9f6a5a9e51535a0d015 /opts.go
parent9fb540642acc6dfcc6816291a832a8ea56973f09 (diff)
Add documentation for GetLong
Diffstat (limited to 'opts.go')
-rw-r--r--opts.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/opts.go b/opts.go
index b8c8b07..71518e4 100644
--- a/opts.go
+++ b/opts.go
@@ -112,6 +112,21 @@ func Get(args []string, optstr string) (flags []Flag, optind int, err error) {
return flags, i, nil
}
+// GetLong parses the command-line arguments in args according to opts.
+//
+// This function is identical to [Get] except it parses according to a
+// [LongOpt] slice instead of an opt-string, and it parses long-options.
+// When parsing, GetLong will also accept incomplete long-options if they
+// are ambiguous. For example, given the following definition of opts:
+//
+// opts := []LongOpt{
+// {Short: 'a', Long: "add", Arg: None},
+// {Short: 'd', Long: "delete", Arg: None},
+// {Short: 'D', Long: "defer", Arg: None},
+// }
+//
+// The options ‘--a’ and ‘--ad’ will parse as ‘--add’. The option ‘--de’
+// will not parse however as it is ambiguous.
func GetLong(args []string, opts []LongOpt) (flags []Flag, optind int, err error) {
if len(args) == 0 {
return