|
| 1 | +use cargo_test_support::cargo_test; |
1 | 2 | use completest_pty::Runtime;
|
| 3 | +use snapbox::assert_data_eq; |
| 4 | + |
| 5 | +#[cargo_test] |
| 6 | +fn bash() { |
| 7 | + let input = "cargo \t\t"; |
| 8 | + let expected = snapbox::str![ |
| 9 | + "% |
| 10 | +--version --help check install read-manifest update |
| 11 | +--list -V clean locate-project remove vendor |
| 12 | +--explain -v config login report verify-project |
| 13 | +--verbose -q doc logout run version |
| 14 | +--quiet -C fetch metadata rustc yank |
| 15 | +--color -Z fix new rustdoc |
| 16 | +--locked -h generate-lockfile owner search |
| 17 | +--offline add help package test |
| 18 | +--frozen bench info pkgid tree |
| 19 | +--config build init publish uninstall " |
| 20 | + ]; |
| 21 | + let actual = complete(input, "bash"); |
| 22 | + assert_data_eq!(actual, expected); |
| 23 | +} |
| 24 | + |
| 25 | +#[cargo_test] |
| 26 | +fn elvish() { |
| 27 | + let input = "cargo \t\t"; |
| 28 | + let expected = snapbox::str![ |
| 29 | + "% cargo |
| 30 | +COMPLETING argument |
| 31 | +--color --version check install read-manifest update |
| 32 | +--config -C clean locate-project remove vendor |
| 33 | +--explain -V config login report verify-project |
| 34 | +--frozen -Z doc logout run version |
| 35 | +--help -h fetch metadata rustc yank |
| 36 | +--list -q fix new rustdoc |
| 37 | +--locked -v generate-lockfile owner search |
| 38 | +--offline add help package test |
| 39 | +--quiet bench info pkgid tree |
| 40 | +--verbose build init publish uninstall " |
| 41 | + ]; |
| 42 | + let actual = complete(input, "elvish"); |
| 43 | + assert_data_eq!(actual, expected); |
| 44 | +} |
| 45 | + |
| 46 | +#[cargo_test] |
| 47 | +fn fish() { |
| 48 | + let input = "cargo \t\t"; |
| 49 | + let expected = snapbox::str![ |
| 50 | + "% cargo |
| 51 | +--version (Print version info and exit) |
| 52 | +--list (List installed commands) |
| 53 | +--explain (Provide a detailed explanation of a rustc error message) |
| 54 | +--verbose (Use verbose output (-vv very verbose/build.rs output)) |
| 55 | +--quiet (Do not print cargo log messages) |
| 56 | +--color (Coloring: auto, always, never) |
| 57 | +--locked (Assert that `Cargo.lock` will remain unchanged) |
| 58 | +--offline (Run without accessing the network) |
| 59 | +--frozen (Equivalent to specifying both --locked and --offline) |
| 60 | +--config (Override a configuration value) |
| 61 | +--help (Print help) |
| 62 | +-V (Print version info and exit) |
| 63 | +-v (Use verbose output (-vv very verbose/build.rs output)) |
| 64 | +-q (Do not print cargo log messages) |
| 65 | +-C (Change to DIRECTORY before doing anything (nightly-only)) |
| 66 | +-Z (Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details) |
| 67 | +-h (Print help) |
| 68 | +add (Add dependencies to a Cargo.toml manifest file) |
| 69 | +bench (Execute all benchmarks of a local package) |
| 70 | +build (Compile a local package and all of its dependencies) |
| 71 | +check (Check a local package and all of its dependencies for errors) |
| 72 | +clean (Remove artifacts that cargo has generated in the past) |
| 73 | +config (Inspect configuration values) |
| 74 | +doc (Build a package's documentation) |
| 75 | +fetch (Fetch dependencies of a package from the network) |
| 76 | +fix (Automatically fix lint warnings reported by rustc) |
| 77 | +generate-lockfile (Generate the lockfile for a package) |
| 78 | +help (Displays help for a cargo subcommand) |
| 79 | +info (Display information about a package in the registry) |
| 80 | +init (Create a new cargo package in an existing directory) |
| 81 | +install (Install a Rust binary) |
| 82 | +locate-project (Print a JSON representation of a Cargo.toml file's location) |
| 83 | +login (Log in to a registry.) |
| 84 | +logout (Remove an API token from the registry locally) |
| 85 | +metadata (Output the resolved dependencies of a package, the concrete used versions including overrides, in machine-r…) |
| 86 | +new (Create a new cargo package at <path>) |
| 87 | +owner (Manage the owners of a crate on the registry) |
| 88 | +package (Assemble the local package into a distributable tarball) |
| 89 | +pkgid (Print a fully qualified package specification) |
| 90 | +publish (Upload a package to the registry) |
| 91 | +read-manifest (Print a JSON representation of a Cargo.toml manifest.) |
| 92 | +remove (Remove dependencies from a Cargo.toml manifest file) |
| 93 | +report (Generate and display various kinds of reports) |
| 94 | +run (Run a binary or example of the local package) |
| 95 | +rustc (Compile a package, and pass extra options to the compiler) |
| 96 | +rustdoc (Build a package's documentation, using specified custom flags.) |
| 97 | +search (Search packages in the registry. Default registry is crates.io) |
| 98 | +test (Execute all unit and integration tests and build examples of a local package) |
| 99 | +tree (Display a tree visualization of a dependency graph) |
| 100 | +uninstall (Remove a Rust binary) |
| 101 | +update (Update dependencies as recorded in the local lock file) |
| 102 | +vendor (Vendor all dependencies for a project locally) |
| 103 | +verify-project (Check correctness of crate manifest) |
| 104 | +version (Show version information) |
| 105 | +yank (Remove a pushed crate from the index)"]; |
| 106 | + |
| 107 | + let actual = complete(input, "fish"); |
| 108 | + assert_data_eq!(actual, expected); |
| 109 | +} |
| 110 | + |
| 111 | +#[cargo_test] |
| 112 | +fn zsh() { |
| 113 | + let input = "cargo \t\t"; |
| 114 | + let expected = snapbox::str![ |
| 115 | + "% cargo |
| 116 | +--color --version check install read-manifest update |
| 117 | +--config -C clean locate-project remove vendor |
| 118 | +--explain -V config login report verify-project |
| 119 | +--frozen -Z doc logout run version |
| 120 | +--help -h fetch metadata rustc yank |
| 121 | +--list -q fix new rustdoc |
| 122 | +--locked -v generate-lockfile owner search |
| 123 | +--offline add help package test |
| 124 | +--quiet bench info pkgid tree |
| 125 | +--verbose build init publish uninstall " |
| 126 | + ]; |
| 127 | + let actual = complete(input, "zsh"); |
| 128 | + assert_data_eq!(actual, expected); |
| 129 | +} |
2 | 130 |
|
3 | 131 | fn complete(input: &str, shell: &str) -> String {
|
4 | 132 | let shell = shell.into();
|
@@ -53,4 +181,3 @@ source <(CARGO_COMPLETE=zsh cargo)",
|
53 | 181 |
|
54 | 182 | runtime
|
55 | 183 | }
|
56 |
| - |
|
0 commit comments