Skip to content

Commit fba26e1

Browse files
feat(cli): enhance CLI flexibility and fix option precedence
- Exposed library configuration options (delimiter, case mode, strictness, etc.) as CLI flags in `cli/main.go`. - Regenerated CLI command implementations using `gosubc` to support the new flags. - Refactored `strings2` helper functions (`ToCamel`, `ToSnake`, etc.) in `permutations.go` and `types.go` to apply default options before user options, allowing users to override defaults. - Updated `process` function in `cli/main.go` to pass parsed options to `strings2` functions as variadic arguments. - Added a section to `README.md` about the CLI mode. - Added a TODO to `README.md` to support slices for flags when `gosubc` supports it.
1 parent f516b0d commit fba26e1

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ strings2 snake --screaming "hello world"
9292

9393
Options are composable so multiple behaviours can be applied at once. See the documentation in `types.go` for details on further options.
9494

95+
## TODO
96+
97+
- Support slices for flags when the gosubc version supports it.
98+
9599
## License
96100

97101
This project is licensed under the BSD 3-Clause License - see the [LICENSE](LICENSE) file for details.

README.md.orig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ fmt.Println(strings2.ToKebabCase(words, strings2.OptionDelimiter("|")))
8181
fmt.Println(strings2.ToSnakeCase(words, strings2.OptionCaseMode(strings2.CMScreaming)))
8282
```
8383

84+
### CLI Mode
85+
86+
The library also provides a command-line interface that exposes all these options, ensuring that the CLI mode has as much flexibility as the code (without being obligated to use smart defaults).
87+
88+
```bash
89+
# Screaming snake case
90+
strings2 snake --screaming "hello world"
91+
```
92+
8493
Options are composable so multiple behaviours can be applied at once. See the documentation in `types.go` for details on further options.
8594

8695
## License

patch_todo.diff

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--- README.md
2+
+++ README.md
3+
@@ -58,6 +58,10 @@
4+
5+
Options are composable so multiple behaviours can be applied at once. See the documentation in `types.go` for details on further options.
6+
7+
+## TODO
8+
+
9+
+- Support slices for flags when the gosubc version supports it.
10+
+
11+
## License
12+
13+
This project is licensed under the BSD 3-Clause License - see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)