Skip to content

Commit

Permalink
fix: hide deprecated commands from cargo --list
Browse files Browse the repository at this point in the history
This includes

* `git-checkout` (removed)
* `read-manifest` (deprecated)
* `verify-project` (deprecated)
  • Loading branch information
weihanglo committed Oct 28, 2024
1 parent 488713c commit 5d2decc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/bin/cargo/commands/git_checkout.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Removed.
use crate::command_prelude::*;

const REMOVED: &str = "The `git-checkout` command has been removed.";
Expand Down
3 changes: 3 additions & 0 deletions src/bin/cargo/commands/read_manifest.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//! Deprecated.
use crate::command_prelude::*;

pub fn cli() -> Command {
subcommand("read-manifest")
.hide(true)
.about(color_print::cstr!(
"\
Print a JSON representation of a Cargo.toml manifest.
Expand Down
3 changes: 3 additions & 0 deletions src/bin/cargo/commands/verify_project.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
//! Deprecated.
use crate::command_prelude::*;

use std::collections::HashMap;
use std::process;

pub fn cli() -> Command {
subcommand("verify-project")
.hide(true)
.about(
"\
Check correctness of crate manifest.
Expand Down
3 changes: 3 additions & 0 deletions src/bin/cargo/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ fn list_commands(gctx: &GlobalContext) -> BTreeMap<String, CommandInfo> {
}

for cmd in commands::builtin() {
if cmd.is_hide_set() {
continue;
}
commands.insert(
cmd.get_name().to_string(),
CommandInfo::BuiltIn {
Expand Down
2 changes: 0 additions & 2 deletions tests/testsuite/cargo_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ fn list_commands_with_descriptions() {
c alias: check
...
r alias: run
...
read-manifest Print a JSON representation of a Cargo.toml manifest.
...
t alias: test
...
Expand Down

0 comments on commit 5d2decc

Please sign in to comment.