Skip to content

Commit

Permalink
jsonschema: New completion
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Feb 13, 2019
1 parent a4dd187 commit 15fe639
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions completions/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ bashcomp_DATA = 2to3 \
jps \
jshint \
json_xs \
jsonschema \
k3b \
kcov \
kill \
Expand Down
29 changes: 29 additions & 0 deletions completions/jsonschema
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# bash completion for jsonschema -*- shell-script -*-

_jsonschema()
{
local cur prev words cword
_init_completion || return

case $prev in
--help|--error-format|--validator|-[hFV])
return
;;
--instance|-i)
_filedir json
return
;;
esac

if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
return
fi

local args; _count_args "" "-*"
[[ $args -eq 1 ]] || return
_filedir '@(json|schema)'
} &&
complete -F _jsonschema jsonschema

# ex: filetype=sh
1 change: 1 addition & 0 deletions test/t/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ EXTRA_DIST = \
test_jps.py \
test_jq.py \
test_jshint.py \
test_jsonschema.py \
test_json_xs.py \
test_k3b.py \
test_kcov.py \
Expand Down
12 changes: 12 additions & 0 deletions test/t/test_jsonschema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytest


class TestJsonschema:

@pytest.mark.complete("jsonschema ")
def test_1(self, completion):
assert completion

@pytest.mark.complete("jsonschema -")
def test_2(self, completion):
assert completion

0 comments on commit 15fe639

Please sign in to comment.