File tree Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ bashcomp_DATA = 2to3 \
37
37
_cal \
38
38
cancel \
39
39
cardctl \
40
+ carton \
40
41
ccache \
41
42
ccze \
42
43
cfagent \
Original file line number Diff line number Diff line change
1
+ # carton(3pm) completion -*- shell-script -*-
2
+
3
+ _carton_commands ()
4
+ {
5
+ local cmds=$( " ${1:- carton} " usage 2>&1 | \
6
+ command sed -ne ' /.*command.* is one of/{n;p;q}' )
7
+ COMPREPLY+=( $( IFS=" $IFS ," compgen -W " $cmds " -- " $cur " ) )
8
+ }
9
+
10
+ _carton_command_help ()
11
+ {
12
+ local help=$( PERLDOC_PAGER=cat PERLDOC=-otext " ${1:- carton} " -h $2 2>&1 )
13
+ COMPREPLY+=( $( compgen -W ' $help' -- " $cur " ) )
14
+ }
15
+
16
+ _carton ()
17
+ {
18
+ local cur prev words cword split
19
+ _init_completion -s || return
20
+
21
+ local i command
22
+ for (( i= 1 ; i < cword; i++ )) ; do
23
+ case ${words[i]} in
24
+ -* ) ;;
25
+ * ) command=${words[i]} ; break ;;
26
+ esac
27
+ done
28
+
29
+ if [[ -z " $command " ]]; then
30
+ _carton_commands " $1 "
31
+ return
32
+ fi
33
+
34
+ case $prev in
35
+ --version|-v)
36
+ return
37
+ ;;
38
+ --help|-h)
39
+ [[ -n " $command " ]] || _carton_commands " $1 "
40
+ return
41
+ ;;
42
+ --cpanfile)
43
+ if [[ $command == install ]]; then
44
+ _filedir
45
+ return
46
+ fi
47
+ ;;
48
+ --path)
49
+ if [[ $command == install ]]; then
50
+ _filedir -d
51
+ return
52
+ fi
53
+ ;;
54
+ --without)
55
+ if [[ $command == install ]]; then
56
+ local phases=" configure build test runtime develop"
57
+ COMPREPLY+=( $( compgen -W ' $phases' -- " $cur " ) )
58
+ return
59
+ fi
60
+ ;;
61
+ esac
62
+
63
+ $split && return
64
+
65
+ if [[ $cur == -* ]]; then
66
+ [[ $command == @ (help| usage) ]] || COMPREPLY=(--help)
67
+ _carton_command_help " $1 " $command
68
+ fi
69
+
70
+ case $command in
71
+ show|update)
72
+ : # TODO modules completion
73
+ ;;
74
+ esac
75
+ } &&
76
+ complete -F _carton carton
77
+
78
+ # ex: filetype=sh
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ EXTRA_DIST = \
54
54
test_cal.py \
55
55
test_cancel.py \
56
56
test_cardctl.py \
57
+ test_carton.py \
57
58
test_cat.py \
58
59
test_cc.py \
59
60
test_ccache.py \
Original file line number Diff line number Diff line change
1
+ import pytest
2
+
3
+
4
+ class TestCarton :
5
+ @pytest .mark .complete ("carton " , require_cmd = True )
6
+ def test_commands (self , completion ):
7
+ assert all (x in completion for x in "help install" .split ())
8
+
9
+ @pytest .mark .complete ("carton install -" , require_cmd = True )
10
+ def test_install_options (self , completion ):
11
+ assert all (x in completion for x in "--cached --help" .split ())
You can’t perform that action at this time.
0 commit comments