mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:16 +00:00
[ty] Support generate-shell-completion
(#17879)
Some checks are pending
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run
Some checks are pending
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run
## Summary Resolves #15502. `ty generate-shell-completion` now works in a similar manner to `ruff generate-shell-completion`. ## Test Plan Manually: <details> ```shell $ cargo run --package ty generate-shell-completion nushell module completions { # An extremely fast Python type checker. export extern ty [ --help(-h) # Print help --version(-V) # Print version ] # ... } export use completions * ``` </details>
This commit is contained in:
parent
443f62e98d
commit
a33d0d4bf4
4 changed files with 11 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -3955,6 +3955,7 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"argfile",
|
"argfile",
|
||||||
"clap",
|
"clap",
|
||||||
|
"clap_complete_command",
|
||||||
"colored 3.0.0",
|
"colored 3.0.0",
|
||||||
"countme",
|
"countme",
|
||||||
"crossbeam",
|
"crossbeam",
|
||||||
|
|
|
@ -22,6 +22,7 @@ ty_server = { workspace = true }
|
||||||
anyhow = { workspace = true }
|
anyhow = { workspace = true }
|
||||||
argfile = { workspace = true }
|
argfile = { workspace = true }
|
||||||
clap = { workspace = true, features = ["wrap_help", "string"] }
|
clap = { workspace = true, features = ["wrap_help", "string"] }
|
||||||
|
clap_complete_command = { workspace = true }
|
||||||
colored = { workspace = true }
|
colored = { workspace = true }
|
||||||
countme = { workspace = true, features = ["enable"] }
|
countme = { workspace = true, features = ["enable"] }
|
||||||
crossbeam = { workspace = true }
|
crossbeam = { workspace = true }
|
||||||
|
|
|
@ -24,6 +24,10 @@ pub(crate) enum Command {
|
||||||
|
|
||||||
/// Display ty's version
|
/// Display ty's version
|
||||||
Version,
|
Version,
|
||||||
|
|
||||||
|
/// Generate shell completion
|
||||||
|
#[clap(hide = true)]
|
||||||
|
GenerateShellCompletion { shell: clap_complete_command::Shell },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::sync::Mutex;
|
||||||
use crate::args::{Args, CheckCommand, Command, TerminalColor};
|
use crate::args::{Args, CheckCommand, Command, TerminalColor};
|
||||||
use crate::logging::setup_tracing;
|
use crate::logging::setup_tracing;
|
||||||
use anyhow::{anyhow, Context};
|
use anyhow::{anyhow, Context};
|
||||||
use clap::Parser;
|
use clap::{CommandFactory, Parser};
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use crossbeam::channel as crossbeam_channel;
|
use crossbeam::channel as crossbeam_channel;
|
||||||
use rayon::ThreadPoolBuilder;
|
use rayon::ThreadPoolBuilder;
|
||||||
|
@ -68,6 +68,10 @@ fn run() -> anyhow::Result<ExitStatus> {
|
||||||
Command::Server => run_server().map(|()| ExitStatus::Success),
|
Command::Server => run_server().map(|()| ExitStatus::Success),
|
||||||
Command::Check(check_args) => run_check(check_args),
|
Command::Check(check_args) => run_check(check_args),
|
||||||
Command::Version => version().map(|()| ExitStatus::Success),
|
Command::Version => version().map(|()| ExitStatus::Success),
|
||||||
|
Command::GenerateShellCompletion { shell } => {
|
||||||
|
shell.generate(&mut Args::command(), &mut stdout());
|
||||||
|
Ok(ExitStatus::Success)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue