Skip to content

Commit 32b28f4

Browse files
author
Stanislav (Stas) Katkov
committed
Let's update CLI desciptions and examples
1 parent 6799c54 commit 32b28f4

File tree

19 files changed

+437
-104
lines changed

19 files changed

+437
-104
lines changed

cmd/count.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,30 @@ import (
1212
)
1313

1414
var countCmd = &cobra.Command{
15-
Use: "count",
16-
Short: "Character, spaces and word counter",
17-
Long: "Count characters, spaces and words in a string",
15+
Use: "count [string or file]",
16+
Short: "Count characters, spaces, and words in text",
17+
Long: `Count characters, spaces, and words in text input.
18+
19+
Provides detailed statistics including character count, space count, and word count
20+
in a formatted table. Input can be a string argument or piped from stdin.`,
1821
Example: ` # Count text from a string
1922
devtui count "test me please"
23+
devtui count "hello world"
2024
2125
# Count text from stdin
22-
cat testdata/example.csv | devtui count
23-
echo "hello world" | devtui count`,
26+
echo "hello world" | devtui count
27+
cat document.txt | devtui count
28+
29+
# Count text from file
30+
devtui count < document.txt
31+
cat README.md | devtui count
32+
33+
# Output to file
34+
devtui count "sample text" > stats.txt
35+
36+
# Chain with other commands
37+
curl -s https://example.com | devtui count
38+
cat article.txt | devtui count`,
2439
Args: cobra.MaximumNArgs(1),
2540
RunE: func(cmd *cobra.Command, args []string) error {
2641
text, err := input.ReadFromArgsOrStdin(cmd, args)

cmd/cssfmt.go

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,35 @@ import (
1212
)
1313

1414
var cssfmtCmd = &cobra.Command{
15-
Use: "cssfmt",
16-
Short: "Format CSS files",
17-
Long: "Format CSS files",
18-
Example: `
19-
cssfmt < testdata/bootstrap.min.css
20-
cssfmt < testdata/bootstrap.min.css --tui # Show results in a TUI
21-
`,
15+
Use: "cssfmt [string or file]",
16+
Short: "Format and prettify CSS files",
17+
Long: `Format and prettify CSS files with customizable indentation and formatting options.
18+
19+
By default, uses 2-space indentation. Use --tab for tab indentation or --indent to specify
20+
custom spacing. Input can be a string argument or piped from stdin.`,
21+
Example: ` # Format CSS from stdin
22+
devtui cssfmt < styles.css
23+
cat minified.css | devtui cssfmt
24+
25+
# Format CSS string argument
26+
devtui cssfmt 'body{margin:0;padding:0}'
27+
28+
# Use tab indentation
29+
devtui cssfmt --tab < styles.css
30+
devtui cssfmt -t < styles.css
31+
32+
# Use custom indent spacing
33+
devtui cssfmt --indent 4 < styles.css
34+
devtui cssfmt -i 4 < styles.css
35+
36+
# Output to file
37+
devtui cssfmt < input.css > formatted.css
38+
39+
# Show results in interactive TUI
40+
devtui cssfmt --tui < styles.css
41+
42+
# Chain with other commands
43+
curl -s https://example.com/styles.css | devtui cssfmt`,
2244
Args: cobra.MaximumNArgs(1),
2345
RunE: func(cmd *cobra.Command, args []string) error {
2446
if flagTui {

cmd/cssmin.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,27 @@ import (
99
)
1010

1111
var cssminCmd = &cobra.Command{
12-
Use: "cssmin",
13-
Short: "Minify CSS files",
14-
Long: "Minify CSS files",
15-
Example: "cssmin < testdata/bootstrap.min.css",
16-
Args: cobra.MaximumNArgs(1),
12+
Use: "cssmin [string or file]",
13+
Short: "Minify CSS files by removing whitespace and unnecessary characters",
14+
Long: `Minify CSS files by removing whitespace, line breaks, and unnecessary characters.
15+
16+
This reduces file size for production use while maintaining CSS functionality.
17+
Input can be a string argument or piped from stdin.`,
18+
Example: ` # Minify CSS from stdin
19+
devtui cssmin < styles.css
20+
cat source.css | devtui cssmin
21+
22+
# Minify CSS string argument
23+
devtui cssmin 'body { margin: 0; padding: 0; }'
24+
25+
# Output to file
26+
devtui cssmin < input.css > minified.css
27+
cat styles.css | devtui cssmin > styles.min.css
28+
29+
# Chain with other commands
30+
curl -s https://example.com/styles.css | devtui cssmin
31+
devtui cssfmt < messy.css | devtui cssmin`,
32+
Args: cobra.MaximumNArgs(1),
1733
RunE: func(cmd *cobra.Command, args []string) error {
1834
cssformat := csstool.NewCSSFormat(0, false, nil)
1935
cssformat.AlwaysSemicolon = false

cmd/csv2md.go

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,31 @@ import (
1313
// @see https://git.axenov.dev/anthony/csv2md/src/branch/master
1414

1515
var csv2mdCmd = &cobra.Command{
16-
Use: "csv2md",
17-
Short: "Convert CSV to Markdown Table",
18-
Long: "Convert CSV to Markdown Table",
19-
Example: ` devtui csv2md -t < example.tsv - convert tsv from stdin and view result in stdout
20-
devtui csv2md < example.tsv > output.md - convert tsv from stdin and write result in new file
21-
cat example.tsv | devtui csv2md - convert tsv from stdin and view result in stdout`,
16+
Use: "csv2md [string or file]",
17+
Short: "Convert CSV to Markdown table format",
18+
Long: `Convert CSV (Comma-Separated Values) to Markdown table format for documentation.
19+
20+
Input can be piped from stdin or read from a file. Use --align to align column widths
21+
and --header to add a main heading (h1) to the output.`,
22+
Example: ` # Convert CSV from stdin
23+
devtui csv2md < example.csv
24+
cat data.csv | devtui csv2md
25+
26+
# Output to file
27+
devtui csv2md < input.csv > output.md
28+
cat data.csv | devtui csv2md > table.md
29+
30+
# Add main header to output
31+
devtui csv2md --header "User Data" < users.csv
32+
devtui csv2md -t "Sales Report" < sales.csv
33+
34+
# Align column widths for better readability
35+
devtui csv2md --align < data.csv
36+
devtui csv2md -a < data.csv
37+
38+
# Combine options
39+
devtui csv2md --header "Results" --align < data.csv
40+
devtui csv2md -t "Results" -a < data.csv`,
2241
Args: cobra.MaximumNArgs(1),
2342
RunE: func(cmd *cobra.Command, args []string) error {
2443

cmd/gqlquery.go

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,45 @@ import (
1515
)
1616

1717
var gqlfmtCmd = &cobra.Command{
18-
Use: "gqlquery",
19-
Short: "Format GraphQL queries",
20-
Long: "Format GraphQL queries for better readability",
21-
Example: `
22-
gqlquery < testdata/query.graphql # Format and output to stdout
23-
gqlquery < testdata/query.graphql > formatted.graphql # Output to file
24-
gqlquery --indent " " --with-comments --with-descriptions < testdata/query.graphql # With formatting options
25-
gqlquery < testdata/query.graphql --tui # Show results in a TUI
26-
`,
18+
Use: "gqlquery [string or file]",
19+
Short: "Format and prettify GraphQL queries",
20+
Long: `Format and prettify GraphQL queries for better readability with customizable formatting options.
21+
22+
By default, uses 2-space indentation and omits descriptions. Use flags to customize
23+
indentation, include comments, or include descriptions. Input can be a string argument
24+
or piped from stdin.`,
25+
Example: ` # Format GraphQL query from stdin
26+
devtui gqlquery < query.graphql
27+
cat query.graphql | devtui gqlquery
28+
29+
# Format GraphQL string argument
30+
devtui gqlquery 'query { user(id: 1) { name email } }'
31+
32+
# Output to file
33+
devtui gqlquery < input.graphql > formatted.graphql
34+
cat query.graphql | devtui gqlquery > pretty.graphql
35+
36+
# Custom indentation (4 spaces)
37+
devtui gqlquery --indent " " < query.graphql
38+
devtui gqlquery -i " " < query.graphql
39+
40+
# Include comments in output
41+
devtui gqlquery --with-comments < query.graphql
42+
devtui gqlquery -c < query.graphql
43+
44+
# Include descriptions in output
45+
devtui gqlquery --with-descriptions < query.graphql
46+
devtui gqlquery -d < query.graphql
47+
48+
# Combine formatting options
49+
devtui gqlquery -i " " -c -d < query.graphql
50+
51+
# Show results in interactive TUI
52+
devtui gqlquery --tui < query.graphql
53+
devtui gqlquery -t < query.graphql
54+
55+
# Chain with other commands
56+
curl -s https://api.example.com/schema.graphql | devtui gqlquery`,
2757
Args: cobra.MaximumNArgs(1),
2858
RunE: func(cmd *cobra.Command, args []string) error {
2959
data, err := input.ReadBytesFromArgsOrStdin(cmd, args)

cmd/jsonfmt.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,26 @@ import (
99
)
1010

1111
var jsonfmtCmd = &cobra.Command{
12-
Use: "jsonfmt",
13-
Short: "Format JSON",
14-
Long: "Format JSON",
15-
Example: `
16-
devtui jsonfmt < testdata/example.json # Format and output to stdout
17-
devtui jsonfmt < testdata/example.json > formatted.json # Output to file
18-
`,
12+
Use: "jsonfmt [string or file]",
13+
Short: "Format and prettify JSON",
14+
Long: `Format and prettify JSON input with proper indentation and syntax highlighting.
15+
16+
Input can be a string argument, piped from stdin, or read from a file.
17+
The output is always valid, properly indented JSON.`,
18+
Example: ` # Format JSON from stdin
19+
devtui jsonfmt < example.json
20+
echo '{"name":"John","age":30}' | devtui jsonfmt
21+
22+
# Format JSON string argument
23+
devtui jsonfmt '{"name":"John","age":30}'
24+
25+
# Output to file
26+
devtui jsonfmt < input.json > formatted.json
27+
cat compact.json | devtui jsonfmt > pretty.json
28+
29+
# Chain with other commands
30+
curl -s https://api.example.com/data | devtui jsonfmt
31+
devtui jsonrepair < broken.json | devtui jsonfmt`,
1932
Args: cobra.MaximumNArgs(1),
2033
RunE: func(cmd *cobra.Command, args []string) error {
2134
data, err := input.ReadBytesFromArgsOrStdin(cmd, args)

cmd/tomlfmt.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,30 @@ import (
1111
)
1212

1313
var tomlfmtCmd = &cobra.Command{
14-
Use: "tomlfmt",
15-
Short: "Format TOML files",
16-
Long: "Format TOML files",
17-
Args: cobra.MaximumNArgs(1),
14+
Use: "tomlfmt [string or file]",
15+
Short: "Format and prettify TOML files",
16+
Long: `Format and prettify TOML (Tom's Obvious Minimal Language) files with proper indentation.
17+
18+
Input can be a string argument or piped from stdin. Use --tui flag to view results
19+
in an interactive terminal interface.`,
20+
Example: ` # Format TOML from stdin
21+
devtui tomlfmt < config.toml
22+
cat app.toml | devtui tomlfmt
23+
24+
# Format TOML string argument
25+
devtui tomlfmt '[package]\nname = "myapp"'
26+
27+
# Output to file
28+
devtui tomlfmt < input.toml > formatted.toml
29+
cat config.toml | devtui tomlfmt > pretty.toml
30+
31+
# Show results in interactive TUI
32+
devtui tomlfmt --tui < config.toml
33+
devtui tomlfmt -t < config.toml
34+
35+
# Chain with other commands
36+
curl -s https://example.com/config.toml | devtui tomlfmt`,
37+
Args: cobra.MaximumNArgs(1),
1838
RunE: func(cmd *cobra.Command, args []string) error {
1939
data, err := input.ReadBytesFromArgsOrStdin(cmd, args)
2040
if err != nil {

cmd/tsv2md.go

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,31 @@ import (
1313
// @see https://git.axenov.dev/anthony/csv2md/src/branch/master
1414

1515
var tsv2mdCmd = &cobra.Command{
16-
Use: "tsv2md",
17-
Short: "Convert TSV to Markdown Table",
18-
Long: "Convert TSV to Markdown Table",
19-
Example: ` devtui tsv2md -t < example.tsv # convert tsv from stdin and view result in stdout
20-
devtui tsv2md < example.tsv > output.md # convert tsv from stdin and write result in new file
21-
cat example.tsv | devtui tsv2md # convert tsv from stdin and view result in stdout`,
16+
Use: "tsv2md [string or file]",
17+
Short: "Convert TSV to Markdown table format",
18+
Long: `Convert TSV (Tab-Separated Values) to Markdown table format for documentation.
19+
20+
Input can be piped from stdin or read from a file. Use --align to align column widths
21+
and --header to add a main heading (h1) to the output.`,
22+
Example: ` # Convert TSV from stdin
23+
devtui tsv2md < example.tsv
24+
cat data.tsv | devtui tsv2md
25+
26+
# Output to file
27+
devtui tsv2md < input.tsv > output.md
28+
cat data.tsv | devtui tsv2md > table.md
29+
30+
# Add main header to output
31+
devtui tsv2md --header "User Data" < users.tsv
32+
devtui tsv2md -t "Sales Report" < sales.tsv
33+
34+
# Align column widths for better readability
35+
devtui tsv2md --align < data.tsv
36+
devtui tsv2md -a < data.tsv
37+
38+
# Combine options
39+
devtui tsv2md --header "Results" --align < data.tsv
40+
devtui tsv2md -t "Results" -a < data.tsv`,
2241
Args: cobra.MaximumNArgs(1),
2342
RunE: func(cmd *cobra.Command, args []string) error {
2443
// Read from args or stdin - the function handles both cases

cmd/xmlfmt.go

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,41 @@ import (
1212
)
1313

1414
var xmlfmtCmd = &cobra.Command{
15-
Use: "xmlfmt",
16-
Short: "Format XML",
17-
Long: "Format XML",
18-
Example: `
19-
xmlfmt < testdata/sample.xml # Format XML from stdin
20-
xmlfmt < testdata/sample.xml > output.xml # Output formatted XML to file
21-
xmlfmt < testdata/sample.xml --tui # Open XML formatter in TUI
22-
`,
15+
Use: "xmlfmt [string or file]",
16+
Short: "Format and prettify XML files",
17+
Long: `Format and prettify XML files with customizable indentation and formatting options.
18+
19+
By default, uses 2-space indentation. Customize with --indent, --prefix, and --nested flags.
20+
Input can be a string argument or piped from stdin.`,
21+
Example: ` # Format XML from stdin
22+
devtui xmlfmt < document.xml
23+
cat unformatted.xml | devtui xmlfmt
24+
25+
# Format XML string argument
26+
devtui xmlfmt '<root><item>value</item></root>'
27+
28+
# Output to file
29+
devtui xmlfmt < input.xml > formatted.xml
30+
cat document.xml | devtui xmlfmt > pretty.xml
31+
32+
# Custom indentation
33+
devtui xmlfmt --indent " " < document.xml
34+
devtui xmlfmt -i "\t" < document.xml
35+
36+
# Add prefix to each line
37+
devtui xmlfmt --prefix " " < document.xml
38+
devtui xmlfmt -p " " < document.xml
39+
40+
# Handle nested tags in comments
41+
devtui xmlfmt --nested < document.xml
42+
devtui xmlfmt -n < document.xml
43+
44+
# Show results in interactive TUI
45+
devtui xmlfmt --tui < document.xml
46+
devtui xmlfmt -t < document.xml
47+
48+
# Chain with other commands
49+
curl -s https://example.com/feed.xml | devtui xmlfmt`,
2350
Args: cobra.MaximumNArgs(1),
2451
RunE: func(cmd *cobra.Command, args []string) error {
2552
// Read all input data from stdin or args

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/skatkov/devtui
22

3-
go 1.25.3
3+
go 1.25.4
44

55
require (
66
github.com/RealAlexandreAI/json-repair v0.0.14

0 commit comments

Comments
 (0)