mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Update dependencies and add CLI completions support
- Updated several dependencies in `Cargo.lock` and `Cargo.toml`, including `anyhow`, `tempfile`, `clap`, and others to their latest versions for improved functionality and security. - Introduced a new `CompletionsCommand` in the CLI to support shell completions, enhancing user experience by allowing users to generate command completions for various shells. These changes aim to keep the project dependencies up-to-date and improve the command-line interface usability.
This commit is contained in:
parent
640b2d3d97
commit
d8d6a53fce
6 changed files with 123 additions and 83 deletions
21
src/cli/completions.rs
Normal file
21
src/cli/completions.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
use std::io;
|
||||
|
||||
use clap::Parser;
|
||||
use clap_complete::{generate, Shell};
|
||||
|
||||
use super::Options;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct CompletionsCommand {
|
||||
/// Shell to generate completions for.
|
||||
#[clap(value_enum)]
|
||||
pub shell: Shell,
|
||||
}
|
||||
|
||||
impl CompletionsCommand {
|
||||
pub fn run(self) -> anyhow::Result<()> {
|
||||
let mut cmd = <Options as clap::CommandFactory>::command();
|
||||
generate(self.shell, &mut cmd, "atlas", &mut io::stdout());
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
mod build;
|
||||
mod clone;
|
||||
mod completions;
|
||||
mod cursor;
|
||||
mod doc;
|
||||
mod fmt_project;
|
||||
|
|
@ -20,6 +21,7 @@ use thiserror::Error;
|
|||
|
||||
pub use self::build::BuildCommand;
|
||||
pub use self::clone::CloneCommand;
|
||||
pub use self::completions::CompletionsCommand;
|
||||
pub use self::cursor::CursorCommand;
|
||||
pub use self::doc::DocCommand;
|
||||
pub use self::fmt_project::FmtProjectCommand;
|
||||
|
|
@ -47,6 +49,7 @@ impl Options {
|
|||
pub fn run(self) -> anyhow::Result<()> {
|
||||
match self.subcommand {
|
||||
Subcommand::Clone(subcommand) => subcommand.run(self.global),
|
||||
Subcommand::Completions(subcommand) => subcommand.run(),
|
||||
Subcommand::Init(subcommand) => subcommand.run(),
|
||||
Subcommand::Serve(subcommand) => subcommand.run(),
|
||||
Subcommand::Build(subcommand) => subcommand.run(),
|
||||
|
|
@ -126,6 +129,7 @@ pub struct ColorChoiceParseError {
|
|||
#[derive(Debug, Parser)]
|
||||
pub enum Subcommand {
|
||||
Clone(CloneCommand),
|
||||
Completions(CompletionsCommand),
|
||||
Init(InitCommand),
|
||||
Serve(ServeCommand),
|
||||
Build(BuildCommand),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue