@@ -15,15 +15,45 @@ import (
1515)
1616
1717var 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 )
0 commit comments