Skip to content

Commit

Permalink
Do not use makefile to generate vcs completions, do it directly in th…
Browse files Browse the repository at this point in the history
…e script. Also add some minor updates to the vcs completions.

darcs-hash:20070224125927-ac50b-f1242b198ea0651c993b045d584262dc32062338.gz
  • Loading branch information
liljencrantz committed Feb 24, 2007
1 parent 73a67c2 commit 0f51d5e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 54 deletions.
15 changes: 0 additions & 15 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -823,21 +823,6 @@ fish.spec: fish.spec.in
./config.status


#
# Completion files which are autogenerated using various scripts
#

share/completions/darcs.fish: make_mercurial_completions.fish
./make_mercurial_completions.fish darcs 'complete -c darcs -n "not __fish_use_subcommand" -a "(test -f _darcs/prefs/repos; and cat _darcs/prefs/repos)" --description "Darcs repo"' 'complete -c darcs -a "test predist boringfile binariesfile" -n "contains setpref (commandline -poc)" -d "woot" -x' >$@

share/completions/hg.fish: make_mercurial_completions.fish
./make_mercurial_completions.fish hg >$@

share/completions/svn.fish: make_mercurial_completions.fish
./make_mercurial_completions.fish svn >$@

share/completions/cvs.fish: make_mercurial_completions.fish
./make_mercurial_completions.fish cvs >$@

#
# Create .rpm file for the current systems architecture and an
Expand Down
88 changes: 54 additions & 34 deletions make_mercurial_completions.fish → make_vcs_completions.fish
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ function complete_from_list
case '?*'
set str $str -x
echo "Don't know how to handle arguments of type '$arg'" >&2
if not set -q unknown
set -g unknown
end
if not contains $arg $unknown
echo "Don't know how to handle arguments of type '$arg'" >&2
set unknown $unknown $arg
end
end
switch $desc
Expand All @@ -85,39 +91,44 @@ function complete_from_list
end
set cmd $argv[1]; or exit 1
function write_completions
echo '
set -g cmd $argv[1]; or return 1
echo "Making completions for $cmd" >&2
echo '
#
# Completions for the '$cmd' command
# This file was autogenerated by the file make_mercurial_completions.fish
# which is shipped with the fish source code
# This file was autogenerated by the file make_vcs_completions.fish
# which is shipped with the fish source code.
#
#
# Completions from commandline
#
'
set -e argv[1]
set -e argv[1]
while count $argv >/dev/null
echo $argv[1]
set -e argv[1]
end
while count $argv >/dev/null
echo $argv[1]
set -e argv[1]
end
eval "function cmd; $cmd \$argv; end"
eval "function cmd; $cmd \$argv; end"
set -l cmd_str
set -l cmd_str
switch $cmd
case svn
switch $cmd
case svn
function list_subcommand
set cmd1 '\([^ ]*\)'
set cmd2 '\([^,)]*\)'
set cmdn '\(, \([^,)]*\)\|\)'
set svn_re '^ *'$cmd1'\( ('$cmd2$cmdn$cmdn')\|\).*$'
set svn_re '^ *'$cmd1'\( ('$cmd2$cmdn$cmdn')\|\).*$'
cmd help|sed -ne 's/'$svn_re'/\1\n\3\n\5\n\7/p'| grep .
end
Expand All @@ -130,23 +141,22 @@ switch $cmd
cmd help $argv | sed -n -e 's/'$re'/\1\t\2\t\3\t\5/p'
end
for i in (list_subcommand)
set desc (cmd help $i|head -n 1|sed -e 's/[^:]*: *\(.*[^.]\)\(\|\\.\)$/\1/')
set desc (esc $desc)
set cmd_str $cmd_str "-a $i --description '$desc'"
end
case cvs
case cvs
function list_subcommand
cmd --help-commands 2>| sed -n -e 's/^ *\([^ ][^ ]*\) .*$/\1/p'
cmd --help-commands 2>| sed -n -e 's/^ *\([^ ][^ ]*\) .*$/\1/p'
end
set short_exp '\(-.\)'
set arg_exp '\(\| [^ \t][^ \t]*\)'
set desc_exp '\([\t ]*:[\t ]*\|\)\([^ ].*\)'
set re '^[ \t]*'$short_exp$arg_exp'[ \t]*'$desc_exp'$'
set -g re '^[ \t]*'$short_exp$arg_exp'[ \t]*'$desc_exp'$'
function list_subcommand_help
#'s/^[ \t]*\(-.\)[ \t]\([^- \t][^ \t]*\)*[ \t]*\([^-].*\)$/\1\t\2\t\3/p'
Expand All @@ -168,44 +178,54 @@ switch $cmd
set cmd_str $cmd_str "-a $exploded[1] --description '"(esc $exploded[2])"'"
end
case '*'
case '*'
function list_subcommand
cmd help | sed -n -e 's/^ *\([^ ][^ ]*\) .*$/\1/p'
cmd help | sed -n -e 's/^ *\([^ ][^ ]*\) .*$/\1/p'
end
function list_subcommand_help
set short_exp '\(-.\|\)\( [^ -][^ ]*\|\)'
set long_exp '\(--[^ =,]*\)'
set arg_exp '\(\|[= ][^ ][^ ]*\)'
set desc_exp '\([\t ]*:[\t ]*\|\)\([^ ].*[^.]\)'
set re "^ *$short_exp *$long_exp$arg_exp *$desc_exp\(\|\\.\)\$"
set -l short_exp '\(-.\|\)\( [^ -][^ ]*\|\)'
set -l long_exp '\(--[^ =,]*\)'
set -l arg_exp '\(\|[= ][^ ][^ ]*\)'
set -l desc_exp '\([\t ]*:[\t ]*\|\)\([^ ].*[^.]\)'
set -l re "^ *$short_exp *$long_exp$arg_exp *$desc_exp\(\|\\.\)\$"
cmd help $argv | sed -n -e 's/'$re'/\1\t\3\t\4\t\6/p'
end
set cmd_str (cmd help | sed -n -e 's/^ *\([^ ][^ ]*\)[\t ]*\([^ ].*[^.]\)\(\|\\.\)$/-a \1 --description \'\2\'/p')
end
echo '
end
echo '
#
# subcommands
#
'
printf "complete -c $cmd -n '__fish_use_subcommand' -x %s\n" $cmd_str
printf "complete -c $cmd -n '__fish_use_subcommand' -x %s\n" $cmd_str
for i in (list_subcommand)
for i in (list_subcommand)
echo '
echo '
#
# Completions for the \''$i'\' subcommand
#
'
complete_from_list "-n 'contains \\'$i\\' (commandline -poc)'" (list_subcommand_help $i)
complete_from_list "-n 'contains \\'$i\\' (commandline -poc)'" (list_subcommand_help $i)
end
echo \n\n
end
echo \n\n
set darcs_comp 'complete -c darcs -n "not __fish_use_subcommand" -a "(test -f _darcs/prefs/repos; and cat _darcs/prefs/repos)" --description "Darcs repo"'
set darcs_comp $darcs_comp 'complete -c darcs -a "test predist boringfile binariesfile" -n "contains setpref (commandline -poc)" --description "Set the specified option" -x'
write_completions darcs $darcs_comp >share/completions/darcs.fish
write_completions hg >share/completions/hg.fish
write_completions svn >share/completions/svn.fish
write_completions cvs >share/completions/cvs.fish
1 change: 1 addition & 0 deletions share/completions/darcs.fish
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#

complete -c darcs -n "not __fish_use_subcommand" -a "(test -f _darcs/prefs/repos; and cat _darcs/prefs/repos)" --description "Darcs repo"
complete -c darcs -a "test predist boringfile binariesfile" -n "contains setpref (commandline -poc)" --description "Set the specified option" -x

#
# subcommands
Expand Down
13 changes: 8 additions & 5 deletions share/completions/svn.fish
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ complete -c svn -n '__fish_use_subcommand' -x -a delete --description 'Remove fi
complete -c svn -n '__fish_use_subcommand' -x -a del --description 'Remove files and directories from version control'
complete -c svn -n '__fish_use_subcommand' -x -a remove --description 'Remove files and directories from version control'
complete -c svn -n '__fish_use_subcommand' -x -a rm --description 'Remove files and directories from version control'
complete -c svn -n '__fish_use_subcommand' -x -a diff --description 'Display the differences between two paths'
complete -c svn -n '__fish_use_subcommand' -x -a di --description 'Display the differences between two paths'
complete -c svn -n '__fish_use_subcommand' -x -a diff --description 'Display the differences between two revisions or paths'
complete -c svn -n '__fish_use_subcommand' -x -a di --description 'Display the differences between two revisions or paths'
complete -c svn -n '__fish_use_subcommand' -x -a export --description 'Create an unversioned copy of a tree'
complete -c svn -n '__fish_use_subcommand' -x -a help --description 'Describe the usage of this program or its subcommands'
complete -c svn -n '__fish_use_subcommand' -x -a ? --description 'Describe the usage of this program or its subcommands'
Expand Down Expand Up @@ -94,6 +94,7 @@ complete -c svn -n 'contains \'add\' (commandline -poc)' -l no-auto-props --desc

complete -c svn -n 'contains \'blame\' (commandline -poc)' -l incremental --description 'Give output suitable for concatenation'
complete -c svn -n 'contains \'blame\' (commandline -poc)' -l xml --description 'Output in XML'
complete -c svn -n 'contains \'blame\' (commandline -poc)' -l force --description 'Force operation to run'
complete -c svn -n 'contains \'blame\' (commandline -poc)' -l username -x --description 'Specify a username ARG'
complete -c svn -n 'contains \'blame\' (commandline -poc)' -l password -x --description 'Specify a password ARG'
complete -c svn -n 'contains \'blame\' (commandline -poc)' -l no-auth-cache --description 'Do not cache authentication tokens'
Expand All @@ -107,6 +108,7 @@ complete -c svn -n 'contains \'blame\' (commandline -poc)' -l config-dir -x --de

complete -c svn -n 'contains \'praise\' (commandline -poc)' -l incremental --description 'Give output suitable for concatenation'
complete -c svn -n 'contains \'praise\' (commandline -poc)' -l xml --description 'Output in XML'
complete -c svn -n 'contains \'praise\' (commandline -poc)' -l force --description 'Force operation to run'
complete -c svn -n 'contains \'praise\' (commandline -poc)' -l username -x --description 'Specify a username ARG'
complete -c svn -n 'contains \'praise\' (commandline -poc)' -l password -x --description 'Specify a password ARG'
complete -c svn -n 'contains \'praise\' (commandline -poc)' -l no-auth-cache --description 'Do not cache authentication tokens'
Expand All @@ -120,6 +122,7 @@ complete -c svn -n 'contains \'praise\' (commandline -poc)' -l config-dir -x --d

complete -c svn -n 'contains \'annotate\' (commandline -poc)' -l incremental --description 'Give output suitable for concatenation'
complete -c svn -n 'contains \'annotate\' (commandline -poc)' -l xml --description 'Output in XML'
complete -c svn -n 'contains \'annotate\' (commandline -poc)' -l force --description 'Force operation to run'
complete -c svn -n 'contains \'annotate\' (commandline -poc)' -l username -x --description 'Specify a username ARG'
complete -c svn -n 'contains \'annotate\' (commandline -poc)' -l password -x --description 'Specify a password ARG'
complete -c svn -n 'contains \'annotate\' (commandline -poc)' -l no-auth-cache --description 'Do not cache authentication tokens'
Expand All @@ -133,6 +136,7 @@ complete -c svn -n 'contains \'annotate\' (commandline -poc)' -l config-dir -x -

complete -c svn -n 'contains \'ann\' (commandline -poc)' -l incremental --description 'Give output suitable for concatenation'
complete -c svn -n 'contains \'ann\' (commandline -poc)' -l xml --description 'Output in XML'
complete -c svn -n 'contains \'ann\' (commandline -poc)' -l force --description 'Force operation to run'
complete -c svn -n 'contains \'ann\' (commandline -poc)' -l username -x --description 'Specify a username ARG'
complete -c svn -n 'contains \'ann\' (commandline -poc)' -l password -x --description 'Specify a password ARG'
complete -c svn -n 'contains \'ann\' (commandline -poc)' -l no-auth-cache --description 'Do not cache authentication tokens'
Expand Down Expand Up @@ -316,6 +320,7 @@ complete -c svn -n 'contains \'diff\' (commandline -poc)' -l new -x --descriptio
complete -c svn -n 'contains \'diff\' (commandline -poc)' -l diff-cmd -x --description 'Use ARG as diff command'
complete -c svn -n 'contains \'diff\' (commandline -poc)' -l no-diff-deleted --description 'Do not print differences for deleted files'
complete -c svn -n 'contains \'diff\' (commandline -poc)' -l notice-ancestry --description 'Notice ancestry when calculating differences'
complete -c svn -n 'contains \'diff\' (commandline -poc)' -l summarize --description 'Show a summary of the results'
complete -c svn -n 'contains \'diff\' (commandline -poc)' -l force --description 'Force operation to run'
complete -c svn -n 'contains \'diff\' (commandline -poc)' -l username -x --description 'Specify a username ARG'
complete -c svn -n 'contains \'diff\' (commandline -poc)' -l password -x --description 'Specify a password ARG'
Expand All @@ -333,6 +338,7 @@ complete -c svn -n 'contains \'di\' (commandline -poc)' -l new -x --description
complete -c svn -n 'contains \'di\' (commandline -poc)' -l diff-cmd -x --description 'Use ARG as diff command'
complete -c svn -n 'contains \'di\' (commandline -poc)' -l no-diff-deleted --description 'Do not print differences for deleted files'
complete -c svn -n 'contains \'di\' (commandline -poc)' -l notice-ancestry --description 'Notice ancestry when calculating differences'
complete -c svn -n 'contains \'di\' (commandline -poc)' -l summarize --description 'Show a summary of the results'
complete -c svn -n 'contains \'di\' (commandline -poc)' -l force --description 'Force operation to run'
complete -c svn -n 'contains \'di\' (commandline -poc)' -l username -x --description 'Specify a username ARG'
complete -c svn -n 'contains \'di\' (commandline -poc)' -l password -x --description 'Specify a password ARG'
Expand All @@ -359,23 +365,20 @@ complete -c svn -n 'contains \'export\' (commandline -poc)' -l ignore-externals
# Completions for the 'help' subcommand
#

complete -c svn -n 'contains \'help\' (commandline -poc)' -l version --description 'Print client version info'
complete -c svn -n 'contains \'help\' (commandline -poc)' -l config-dir -x --description 'Read user configuration files from directory ARG'


#
# Completions for the '?' subcommand
#

complete -c svn -n 'contains \'?\' (commandline -poc)' -l version --description 'Print client version info'
complete -c svn -n 'contains \'?\' (commandline -poc)' -l config-dir -x --description 'Read user configuration files from directory ARG'


#
# Completions for the 'h' subcommand
#

complete -c svn -n 'contains \'h\' (commandline -poc)' -l version --description 'Print client version info'
complete -c svn -n 'contains \'h\' (commandline -poc)' -l config-dir -x --description 'Read user configuration files from directory ARG'


Expand Down

0 comments on commit 0f51d5e

Please sign in to comment.