You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rootCmd.Flags().StringArrayVarP(&inputFiles, "input", "i", []string{}, "input files (can be repeated)")
423
+
424
+
// Alternative: StringSliceVarP for comma-separated values
425
+
// rootCmd.Flags().StringSliceVarP(&inputFiles, "input", "i", []string{}, "input files (comma-separated or repeated)")
426
+
}
427
+
```
428
+
429
+
Usage examples:
430
+
-`myapp --input file1.txt --input file2.txt`
431
+
-`myapp -i file1.txt -i file2.txt`
432
+
- With StringSlice: `myapp --input file1.txt,file2.txt,file3.txt`
433
+
434
+
**Note**: Both `CountVar` and array flags leverage the underlying [pflag](https://github.com/spf13/pflag) library's support for repeated flags.
435
+
369
436
## Positional and Custom Arguments
370
437
371
438
Validation of positional arguments can be specified using the `Args` field of `Command`.
0 commit comments