summaryrefslogtreecommitdiff
path: root/argv.match.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-28 23:42:23 -0500
committerJeff Carr <[email protected]>2025-10-28 23:42:23 -0500
commitbca3f42ae8ddf7e56c93a143b915a8dc9f3326f4 (patch)
tree3f0cab09e18401b79c26e1b46acfdf80b141577b /argv.match.go
parent6b78f1857fe35d39bfef3e5e8a03cbd0e71fa169 (diff)
rename now that things are getting cleaner
Diffstat (limited to 'argv.match.go')
-rw-r--r--argv.match.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/argv.match.go b/argv.match.go
new file mode 100644
index 0000000..2039499
--- /dev/null
+++ b/argv.match.go
@@ -0,0 +1,51 @@
+package argvpb
+
+import "strings"
+
+func (pb *Argv) IsMatch(match string) bool {
+ parts := strings.Split(match, ".")
+ pb.debugf("IsMatch() parts (%v)", parts)
+ for _, part := range parts {
+ var found bool
+ for _, v := range pb.Real {
+ if part == v {
+ found = true
+ }
+ }
+ if found {
+ continue
+ }
+ return false
+ }
+ return true
+}
+
+func Len() int {
+ counter := 0
+ for _, s := range PB.Real {
+ s = strings.TrimSpace(s)
+ if s == "" {
+ continue
+ }
+ if strings.HasPrefix(s, "--") {
+ continue
+ }
+ counter += 1
+ }
+ return counter
+}
+
+func Real() []string {
+ var clean []string
+ for _, s := range PB.Real {
+ s = strings.TrimSpace(s)
+ if s == "" {
+ continue
+ }
+ if strings.HasPrefix(s, "--argv") {
+ continue
+ }
+ clean = append(clean, s)
+ }
+ return clean
+}