Skip to content

Commit c6bef13

Browse files
authored
Fix minor shell auto-completion mismatches (#587)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 7020076 commit c6bef13

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

completion/jsonschema.bash

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ _jsonschema() {
1111
previous=""
1212
fi
1313

14-
commands="validate metaschema compile test fmt lint bundle inspect encode decode version help"
14+
commands="validate metaschema compile test fmt lint bundle inspect canonicalize encode decode version help"
1515

1616
global_options="--verbose -v --resolve -r --default-dialect -d --json -j --http -h"
1717

@@ -59,7 +59,7 @@ _jsonschema() {
5959

6060
case "${command}" in
6161
validate)
62-
local options="--http -h --benchmark -b --loop -l --extension -e --ignore -i --trace -t --fast -f --template -m"
62+
local options="--benchmark -b --loop -l --extension -e --ignore -i --trace -t --fast -f --template -m"
6363
if [[ ${current} == -* ]]
6464
then
6565
COMPREPLY=( $(compgen -W "${options} ${global_options}" -- "${current}") )
@@ -68,7 +68,7 @@ _jsonschema() {
6868
fi
6969
;;
7070
metaschema)
71-
local options="--http -h --extension -e --ignore -i --trace -t"
71+
local options="--extension -e --ignore -i --trace -t"
7272
if [[ ${current} == -* ]]
7373
then
7474
COMPREPLY=( $(compgen -W "${options} ${global_options}" -- "${current}") )
@@ -77,7 +77,7 @@ _jsonschema() {
7777
fi
7878
;;
7979
compile)
80-
local options="--http -h --extension -e --ignore -i --fast -f --minify -m"
80+
local options="--extension -e --ignore -i --fast -f --minify -m"
8181
if [[ ${current} == -* ]]
8282
then
8383
COMPREPLY=( $(compgen -W "${options} ${global_options}" -- "${current}") )
@@ -86,7 +86,7 @@ _jsonschema() {
8686
fi
8787
;;
8888
test)
89-
local options="--http -h --extension -e --ignore -i"
89+
local options="--extension -e --ignore -i"
9090
if [[ ${current} == -* ]]
9191
then
9292
COMPREPLY=( $(compgen -W "${options} ${global_options}" -- "${current}") )
@@ -113,7 +113,7 @@ _jsonschema() {
113113
fi
114114
;;
115115
bundle)
116-
local options="--http -h --extension -e --ignore -i --without-id -w"
116+
local options="--extension -e --ignore -i --without-id -w"
117117
if [[ ${current} == -* ]]
118118
then
119119
COMPREPLY=( $(compgen -W "${options} ${global_options}" -- "${current}") )
@@ -129,6 +129,14 @@ _jsonschema() {
129129
COMPREPLY=( $(compgen -f -X '!*.json' -X '!*.yaml' -X '!*.yml' -- "${current}") )
130130
fi
131131
;;
132+
canonicalize)
133+
if [[ ${current} == -* ]]
134+
then
135+
COMPREPLY=( $(compgen -W "${global_options}" -- "${current}") )
136+
else
137+
COMPREPLY=( $(compgen -f -X '!*.json' -X '!*.yaml' -X '!*.yml' -- "${current}") )
138+
fi
139+
;;
132140
encode)
133141
if [[ ${current} == -* ]]
134142
then

completion/jsonschema.zsh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ _jsonschema() {
1515
'lint:Lint schemas and optionally fix issues'
1616
'bundle:Inline remote references in a schema'
1717
'inspect:Display schema locations and references'
18+
'canonicalize:Transform a schema into a canonical form'
1819
'encode:Encode JSON using JSON BinPack'
1920
'decode:Decode JSON using JSON BinPack'
2021
'version:Print version information'
@@ -114,6 +115,11 @@ _jsonschema() {
114115
${global_options[@]} \
115116
'1:schema file:_files -g "*.json *.yaml *.yml"'
116117
;;
118+
canonicalize)
119+
_arguments \
120+
${global_options[@]} \
121+
'1:schema file:_files -g "*.json *.yaml *.yml"'
122+
;;
117123
encode)
118124
_arguments \
119125
${global_options[@]} \

src/main.cc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Global Options:
2121
--default-dialect, -d <uri> Specify the URI for the default dialect to be used
2222
if the `$schema` keyword is not set
2323
--json, -j Prefer JSON output if supported
24+
--http, -h Allow network access to resolve remote schemas
2425
2526
Commands:
2627
@@ -32,9 +33,8 @@ Global Options:
3233
3334
Print this command reference help.
3435
35-
validate <schema.json|.yaml> <instance.json|.jsonl|.yaml|directory...> [--http/-h]
36-
[--benchmark/-b] [--loop <iterations>]
37-
[--extension/-e <extension>]
36+
validate <schema.json|.yaml> <instance.json|.jsonl|.yaml|directory...>
37+
[--benchmark/-b] [--loop <iterations>] [--extension/-e <extension>]
3838
[--ignore/-i <schemas-or-directories>] [--trace/-t] [--fast/-f]
3939
[--template/-m <template.json>]
4040
@@ -51,19 +51,18 @@ Global Options:
5151
for error reporting purposes. Make sure they match or you will get
5252
non-sense results.
5353
54-
metaschema [schemas-or-directories...] [--http/-h]
55-
[--extension/-e <extension>]
54+
metaschema [schemas-or-directories...] [--extension/-e <extension>]
5655
[--ignore/-i <schemas-or-directories>] [--trace/-t]
5756
5857
Validate that a schema or a set of schemas are valid with respect
5958
to their metaschemas.
6059
61-
compile <schema.json|.yaml> [--http/-h] [--extension/-e <extension>]
60+
compile <schema.json|.yaml> [--extension/-e <extension>]
6261
[--ignore/-i <schemas-or-directories>] [--fast/-f] [--minify/-m]
6362
6463
Compile the given schema into an internal optimised representation.
6564
66-
test [schemas-or-directories...] [--http/-h] [--extension/-e <extension>]
65+
test [schemas-or-directories...] [--extension/-e <extension>]
6766
[--ignore/-i <schemas-or-directories>]
6867
6968
Run a set of unit tests against a schema.
@@ -84,7 +83,7 @@ Global Options:
8483
Use --list/-l to print a summary of all enabled rules.
8584
Use --indentation/-n to keep indentation when auto-fixing
8685
87-
bundle <schema.json|.yaml> [--http/-h] [--extension/-e <extension>]
86+
bundle <schema.json|.yaml> [--extension/-e <extension>]
8887
[--ignore/-i <schemas-or-directories>] [--without-id/-w]
8988
9089
Perform JSON Schema Bundling on a schema to inline remote references,
@@ -95,7 +94,7 @@ Global Options:
9594
Statically inspect a schema to display schema locations and
9695
references in a human-readable manner.
9796
98-
canonicalize <schema.json|.yaml> [--http/-h]
97+
canonicalize <schema.json|.yaml>
9998
10099
Transform a JSON Schema into a canonical normalized form.
101100
Canonicalization is a process that simplifies a schema into a

test/autocomplete_bash.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ test_completion "jsonschema " "fmt" "Command completion includes fmt"
7171
test_completion "jsonschema " "lint" "Command completion includes lint"
7272
test_completion "jsonschema " "bundle" "Command completion includes bundle"
7373
test_completion "jsonschema " "inspect" "Command completion includes inspect"
74+
test_completion "jsonschema " "canonicalize" "Command completion includes canonicalize"
7475
test_completion "jsonschema " "encode" "Command completion includes encode"
7576
test_completion "jsonschema " "decode" "Command completion includes decode"
7677
test_completion "jsonschema " "version" "Command completion includes version"
@@ -91,4 +92,7 @@ test_completion "jsonschema compile --" "--minify" "Compile includes --minify"
9192
test_completion "jsonschema fmt --" "--check" "Fmt includes --check"
9293
test_completion "jsonschema fmt --" "--keep-ordering" "Fmt includes --keep-ordering"
9394

95+
test_completion "jsonschema canonicalize --" "--http" "Canonicalize includes --http"
96+
test_completion "jsonschema canonicalize --" "--verbose" "Canonicalize includes global option --verbose"
97+
9498
echo "PASS" 1>&2

0 commit comments

Comments
 (0)