summaryrefslogtreecommitdiff
path: root/parse.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-28 05:30:12 -0500
committerJeff Carr <[email protected]>2025-10-28 05:30:12 -0500
commitad6d1a1e535a489ce5e9e602d07ac4c03d753f80 (patch)
tree2a07bfff60460a3767695978cf16f7ee7e7b0003 /parse.go
parent44581edefc99b1b444b02b900ff997ab1dba3ef8 (diff)
rm junk. add Match()
Diffstat (limited to 'parse.go')
-rw-r--r--parse.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/parse.go b/parse.go
index 4c47316..cc2161e 100644
--- a/parse.go
+++ b/parse.go
@@ -168,6 +168,7 @@ type Parser struct {
config Config
version string
description string
+ match func() bool
epilogue string
// the following field changes during processing of command line arguments
@@ -190,6 +191,12 @@ type Described interface {
Description() string
}
+// will let the application provide matches for autocomplete
+type Matched interface {
+ // the application should return true if it's happy with itself
+ Match() bool
+}
+
// Epilogued is the interface that the destination struct should implement to
// add an epilogue string at the bottom of the help message.
type Epilogued interface {
@@ -300,6 +307,9 @@ func NewParser(config Config, dests ...interface{}) (*Parser, error) {
if dest, ok := dest.(Described); ok {
p.description = dest.Description()
}
+ if dest, ok := dest.(Matched); ok {
+ p.match = dest.Match
+ }
if dest, ok := dest.(Epilogued); ok {
p.epilogue = dest.Epilogue()
}