Skip to content

Commit

Permalink
chsh, pwck: try _parse_help before _parse_usage
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed May 8, 2019
1 parent 06cea18 commit 696f90d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion completions/_chsh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ _chsh()
esac

if [[ "$cur" == -* ]]; then
COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
local opts=$(_parse_help "$1")
COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") )
else
_allowed_users
fi
Expand Down
3 changes: 2 additions & 1 deletion completions/pwck
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ _pwck()
_init_completion || return

if [[ "$cur" == -* ]]; then
COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
local opts=$(_parse_help "$1")
COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") )
return
fi

Expand Down
4 changes: 4 additions & 0 deletions test/t/test_chsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ def test_1(self, completion):
@pytest.mark.complete("chsh -s ")
def test_2(self, completion):
assert completion

@pytest.mark.complete("chsh -")
def test_3(self, completion):
assert completion
4 changes: 4 additions & 0 deletions test/t/test_pwck.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ class TestPwck:
@pytest.mark.complete("pwck ")
def test_1(self, completion):
assert completion

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

0 comments on commit 696f90d

Please sign in to comment.