aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/completions
diff options
context:
space:
mode:
authorGravatar Bheesham Persaud <bheesham.persaud@live.ca>2015-09-19 15:04:53 -0400
committerGravatar Bheesham Persaud <bheesham.persaud@live.ca>2015-10-26 21:39:16 -0400
commit46fbfaaa83d4cf93ea44c8faf0f3f44c593f95e4 (patch)
treedc4f9428840ec7aab5e26c5341a6a48a604fc1d7 /share/completions
parent09bd938e252fd983fb93a50e5c177b4a41642ce0 (diff)
Add cargo and rustc completion.
rustc.fish makes heavy use of the `string` commands.
Diffstat (limited to 'share/completions')
-rw-r--r--share/completions/cargo.fish91
-rw-r--r--share/completions/rustc.fish69
2 files changed, 160 insertions, 0 deletions
diff --git a/share/completions/cargo.fish b/share/completions/cargo.fish
new file mode 100644
index 00000000..7402427d
--- /dev/null
+++ b/share/completions/cargo.fish
@@ -0,0 +1,91 @@
+# Tab completion for cargo (https://github.com/rust-lang/cargo).
+complete -e -c cargo
+
+complete -c cargo -s h -l help
+complete -c cargo -s V -l version -d 'Print version info and exit'
+complete -c cargo -l list -d 'List installed commands'
+complete -c cargo -s v -l verbose -d 'Use verbose output'
+complete -c cargo -s q -l quiet -d 'No output printed to stdout'
+
+set __fish_cargo_subcommands (cargo --list | tail -n +2 | tr -d " ")
+
+complete -c cargo -f -c cargo -n '__fish_use_subcommand' -a '$__fish_cargo_subcommands'
+complete -c cargo -x -c cargo -n '__fish_seen_subcommand_from help' -a '$__fish_cargo_subcommands'
+
+for x in bench build clean doc fetch generate-lockfile \
+ locate-project package pkgid publish \
+ read-manifest run rustc test update \
+ verify-project;
+ complete -c cargo -r -n "__fish_seen_subcommand_from $x" -l manifest-path -d 'path to the manifest to compile'
+end
+
+for x in bench build clean doc rustc test update;
+ complete -c cargo -x -n "__fish_seen_subcommand_from $x" -s p -l spec -d 'Package to build'
+end
+
+for x in bench build clean doc run rustc test;
+ complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l target -d 'Build for the target triple'
+end
+
+for x in bench build rustc test;
+ complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l bench -d 'Only the specified benchmark'
+ complete -c cargo -n "__fish_seen_subcommand_from $x" -l lib -d 'Only this package\'s library'
+ complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l test -d 'Only the specified test'
+end
+
+for x in bench build run rustc test;
+ complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l bin -d 'Only the specified binary'
+ complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l example -d 'Only the specified example'
+end
+
+for x in build run rustc test;
+ complete -c cargo -n "__fish_seen_subcommand_from $x" -l release -d 'Build artifacts in release mode, with optimizations'
+end
+
+for x in bench test;
+ complete -c cargo -n "__fish_seen_subcommand_from $x" -l no-run -d 'Compile but do not run'
+end
+
+for x in bench build doc run rustc test;
+ complete -c cargo -x -n "__fish_seen_subcommand_from $x" -s j -l jobs -d 'Number of jobs to run in parallel'
+ complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l features -d 'Space-separated list of features to also build'
+ complete -c cargo -n "__fish_seen_subcommand_from $x" -l no-default-features -d 'Do not build the `default` feature'
+end
+
+complete -c cargo -n '__fish_seen_subcommand_from doc' -l no-deps -d 'Don\'t build documentation for dependencies'
+
+complete -c cargo -x -n '__fish_seen_subcommand_from new' -l vcs -a 'none hg git' -d 'Specify a vcs to use'
+complete -c cargo -x -n '__fish_seen_subcommand_from new' -l name
+
+# This bin does not take any arguments which is why it is not defined above.
+complete -c cargo -n '__fish_seen_subcommand_from new' -l bin
+
+complete -c cargo -x -n '__fish_seen_subcommand_from git-checkout' -l url
+complete -c cargo -x -n '__fish_seen_subcommand_from git-checkout' -l reference
+
+for x in login publish search;
+ complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l host -d 'The host to submit the request to'
+end
+
+complete -c cargo -n '__fish_seen_subcommand_from doc' -l open -d 'Opens the docs in a browser after the operation'
+
+complete -c cargo -r -n '__fish_seen_subcommand_from owner' -s a -l add -d 'Login of a user to add as an owner'
+complete -c cargo -r -n '__fish_seen_subcommand_from owner' -s r -l remove -d 'Login of a user to remove as an owner'
+
+for x in owner yank;
+ complete -c cargo -r -n "__fish_seen_subcommand_from $x" -l index -d 'Registry index to use'
+end
+
+for x in owner publish yank;
+ complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l token -d 'API token to use when authenticating'
+end
+
+complete -c cargo -n '__fish_seen_subcommand_from package' -l no-verify -d 'Don\'t verify the contents by building them'
+complete -c cargo -n '__fish_seen_subcommand_from package' -l no-metadata -d 'Ignore warnings about a lack of human-usable metadata'
+
+complete -c cargo -n '__fish_seen_subcommand_from update' -l aggressive -d 'Force updating all dependencies of <name> as well'
+complete -c cargo -x -n '__fish_seen_subcommand_from update' -l precise -d 'Update a single dependency to exactly PRECISE'
+
+complete -c cargo -x -n '__fish_seen_subcommand_from yank' -l vers -d 'The version to yank or un-yank'
+complete -c cargo -n '__fish_seen_subcommand_from yank' -l undo -d 'Undo a yank, putting a version back into the index'
+
diff --git a/share/completions/rustc.fish b/share/completions/rustc.fish
new file mode 100644
index 00000000..d5caa03c
--- /dev/null
+++ b/share/completions/rustc.fish
@@ -0,0 +1,69 @@
+# Tab completion for rustc (https://github.com/rust-lang/rust).
+# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
+complete -e -c rustc
+
+complete -c rustc -s h -l help
+
+complete -c rustc -x -l cfg
+complete -c rustc -r -s L -a 'dylib= static= framework='
+complete -c rustc -x -s l -a 'dylib= static= framework='
+complete -c rustc -x -l crate-type -a 'bin lib rlib dylib staticlib'
+complete -c rustc -r -l crate-name
+complete -c rustc -x -l emit -a 'asm llvm-bc llvm-ir obj link dep-info'
+complete -c rustc -x -l print -a 'crate-name file-names sysroot'
+complete -c rustc -s g
+complete -c rustc -s O
+complete -c rustc -r -l out-dir
+complete -c rustc -x -l explain
+complete -c rustc -l test
+complete -c rustc -l target
+complete -c rustc -x -l cap-lints
+complete -c rustc -s V -l version -d 'Print version info and exit'
+complete -c rustc -s v -l verbose -d 'Use verbose output'
+complete -c rustc -f -l extern
+complete -c rustc -f -l sysroot
+complete -c rustc -x -l color -a 'auto always never'
+
+set -l rust_docs (rustc -C help \
+ | string replace -r -i '(\s+)-C(.+)(\s+)--(\s+)([^\n]+)' '$2 $5' \
+ | string trim \
+ | string match -r '^.*[^:]$')
+
+for line in $rust_docs
+ set docs (string split -m 1 ' ' $line)
+ set flag (string replace -r '^([a-z\-]+\=|[a-z\-]+)(.*)' '$1' \
+ $docs[1])
+ complete -c rustc -x -s C -l codegen -a "$flag" -d "$docs[2]"
+end
+
+set -l rust_docs (rustc -Z help \
+ | string replace -r -i '(\s+)-Z(.+)--(\s+)([^\n]+)' '$2 $4' \
+ | string trim \
+ | string match -r '^.*[^:]$')
+
+for line in $rust_docs
+ set docs (string split -m 1 ' ' $line)
+ set flag (string replace -r '^([a-z\-]+\=|[a-z\-]+)(.*)' '$1' \
+ $docs[1])
+ complete -c rustc -x -s Z -a "$flag" -d "$docs[2]"
+end
+
+set -l rust_docs (rustc -W help \
+ | egrep \
+ '(\s+)(.+)(\s+)(allow|warn|deny|forbid)(\s+){2}([^\n]+)' \
+ | string replace -r -i \
+ '(\s+)(.+)(\s+)(allow|warn|deny|forbid)(\s+){2}([^\n]+)' '$2 $6' \
+ | string match -r '^.*[^:]$' \
+ | egrep -v '^(allow|warn|deny|forbid)$' \
+ | egrep -v '^([a-z\-]+)(\s+)(allow|warn|deny|forbid)')
+
+for line in $rust_docs
+ set docs (string split -m 1 ' ' $line)
+ complete -c rustc -x -s W -l warn -a "$docs[1]" -d "$docs[2]"
+ complete -c rustc -x -s A -l allow -a "$docs[1]" -d "$docs[2]"
+ complete -c rustc -x -s D -l deny -a "$docs[1]" -d "$docs[2]"
+ complete -c rustc -x -s F -l forbid -a "$docs[1]" -d "$docs[2]"
+end
+
+set -e rust_codegen
+