Upgrade clap (#568)

This commit is contained in:
Conrad Ludgate 2022-10-18 09:50:22 +01:00 committed by GitHub
parent 3829f82d9c
commit 5e2c438dab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 58 additions and 58 deletions

24
Cargo.lock generated
View file

@ -331,35 +331,33 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "3.2.21" version = "4.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ed5341b2301a26ab80be5cbdced622e80ed808483c52e45e3310a877d3b37d7" checksum = "6bf8832993da70a4c6d13c581f4463c2bdda27b9bf1c5498dc4365543abe6d6f"
dependencies = [ dependencies = [
"atty", "atty",
"bitflags", "bitflags",
"clap_derive", "clap_derive",
"clap_lex", "clap_lex",
"indexmap",
"once_cell", "once_cell",
"strsim", "strsim",
"termcolor", "termcolor",
"textwrap",
] ]
[[package]] [[package]]
name = "clap_complete" name = "clap_complete"
version = "3.2.5" version = "4.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f7a2e0a962c45ce25afce14220bc24f9dade0a1787f185cecf96bfba7847cd8" checksum = "11cba7abac9b56dfe2f035098cdb3a43946f276e6db83b72c4e692343f9aab9a"
dependencies = [ dependencies = [
"clap", "clap",
] ]
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "3.2.18" version = "4.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" checksum = "c42f169caba89a7d512b5418b09864543eeb4d497416c917d7137863bd2076ad"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error", "proc-macro-error",
@ -370,9 +368,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_lex" name = "clap_lex"
version = "0.2.4" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [ dependencies = [
"os_str_bytes", "os_str_bytes",
] ]
@ -1953,12 +1951,6 @@ dependencies = [
"redox_termios", "redox_termios",
] ]
[[package]]
name = "textwrap"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.34" version = "1.0.34"

View file

@ -66,8 +66,8 @@ chrono-english = "0.1.4"
cli-table = { version = "0.4", default-features = false } cli-table = { version = "0.4", default-features = false }
base64 = "0.13.0" base64 = "0.13.0"
crossbeam-channel = "0.5.1" crossbeam-channel = "0.5.1"
clap = { version = "3.1.18", features = ["derive"] } clap = { version = "4.0.14", features = ["derive"] }
clap_complete = "3.1.4" clap_complete = "4.0.2"
fs-err = "2.7" fs-err = "2.7"
whoami = "1.1.2" whoami = "1.1.2"
rpassword = "7.0" rpassword = "7.0"

View file

@ -14,14 +14,14 @@ mod search;
mod stats; mod stats;
#[derive(Subcommand)] #[derive(Subcommand)]
#[clap(infer_subcommands = true)] #[command(infer_subcommands = true)]
pub enum Cmd { pub enum Cmd {
/// Manipulate shell history /// Manipulate shell history
#[clap(subcommand)] #[command(subcommand)]
History(history::Cmd), History(history::Cmd),
/// Import shell history from file /// Import shell history from file
#[clap(subcommand)] #[command(subcommand)]
Import(import::Cmd), Import(import::Cmd),
/// Calculate statistics for your history /// Calculate statistics for your history
@ -31,7 +31,7 @@ pub enum Cmd {
Search(search::Cmd), Search(search::Cmd),
#[cfg(feature = "sync")] #[cfg(feature = "sync")]
#[clap(flatten)] #[command(flatten)]
Sync(sync::Cmd), Sync(sync::Cmd),
} }

View file

@ -20,7 +20,7 @@ use log::debug;
use super::search::format_duration; use super::search::format_duration;
#[derive(Subcommand)] #[derive(Subcommand)]
#[clap(infer_subcommands = true)] #[command(infer_subcommands = true)]
pub enum Cmd { pub enum Cmd {
/// Begins a new command in the history /// Begins a new command in the history
Start { command: Vec<String> }, Start { command: Vec<String> },
@ -28,33 +28,33 @@ pub enum Cmd {
/// Finishes a new command in the history (adds time, exit code) /// Finishes a new command in the history (adds time, exit code)
End { End {
id: String, id: String,
#[clap(long, short)] #[arg(long, short)]
exit: i64, exit: i64,
}, },
/// List all items in history /// List all items in history
List { List {
#[clap(long, short)] #[arg(long, short)]
cwd: bool, cwd: bool,
#[clap(long, short)] #[arg(long, short)]
session: bool, session: bool,
#[clap(long)] #[arg(long)]
human: bool, human: bool,
/// Show only the text of the command /// Show only the text of the command
#[clap(long)] #[arg(long)]
cmd_only: bool, cmd_only: bool,
}, },
/// Get the last command ran /// Get the last command ran
Last { Last {
#[clap(long)] #[arg(long)]
human: bool, human: bool,
/// Show only the text of the command /// Show only the text of the command
#[clap(long)] #[arg(long)]
cmd_only: bool, cmd_only: bool,
}, },
} }

View file

@ -14,7 +14,7 @@ use atuin_client::{
}; };
#[derive(Parser)] #[derive(Parser)]
#[clap(infer_subcommands = true)] #[command(infer_subcommands = true)]
pub enum Cmd { pub enum Cmd {
/// Import history for the current shell /// Import history for the current shell
Auto, Auto,

View file

@ -18,45 +18,45 @@ pub use duration::format_duration;
#[derive(Parser)] #[derive(Parser)]
pub struct Cmd { pub struct Cmd {
/// Filter search result by directory /// Filter search result by directory
#[clap(long, short)] #[arg(long, short)]
cwd: Option<String>, cwd: Option<String>,
/// Exclude directory from results /// Exclude directory from results
#[clap(long = "exclude-cwd")] #[arg(long = "exclude-cwd")]
exclude_cwd: Option<String>, exclude_cwd: Option<String>,
/// Filter search result by exit code /// Filter search result by exit code
#[clap(long, short)] #[arg(long, short)]
exit: Option<i64>, exit: Option<i64>,
/// Exclude results with this exit code /// Exclude results with this exit code
#[clap(long = "exclude-exit")] #[arg(long = "exclude-exit")]
exclude_exit: Option<i64>, exclude_exit: Option<i64>,
/// Only include results added before this date /// Only include results added before this date
#[clap(long, short)] #[arg(long, short)]
before: Option<String>, before: Option<String>,
/// Only include results after this date /// Only include results after this date
#[clap(long)] #[arg(long)]
after: Option<String>, after: Option<String>,
/// How many entries to return at most /// How many entries to return at most
#[clap(long)] #[arg(long)]
limit: Option<i64>, limit: Option<i64>,
/// Open interactive search UI /// Open interactive search UI
#[clap(long, short)] #[arg(long, short)]
interactive: bool, interactive: bool,
/// Use human-readable formatting for time /// Use human-readable formatting for time
#[clap(long)] #[arg(long)]
human: bool, human: bool,
query: Vec<String>, query: Vec<String>,
/// Show only the text of the command /// Show only the text of the command
#[clap(long)] #[arg(long)]
cmd_only: bool, cmd_only: bool,
} }

View file

@ -13,7 +13,7 @@ use atuin_client::{
}; };
#[derive(Parser)] #[derive(Parser)]
#[clap(infer_subcommands = true)] #[command(infer_subcommands = true)]
pub struct Cmd { pub struct Cmd {
/// compute statistics for the specified period, leave blank for statistics since the beginning /// compute statistics for the specified period, leave blank for statistics since the beginning
period: Vec<String>, period: Vec<String>,

View file

@ -8,12 +8,12 @@ mod logout;
mod register; mod register;
#[derive(Subcommand)] #[derive(Subcommand)]
#[clap(infer_subcommands = true)] #[command(infer_subcommands = true)]
pub enum Cmd { pub enum Cmd {
/// Sync with the configured server /// Sync with the configured server
Sync { Sync {
/// Force re-download everything /// Force re-download everything
#[clap(long, short)] #[arg(long, short)]
force: bool, force: bool,
}, },

View file

@ -1,6 +1,6 @@
use std::io; use std::io;
use clap::{AppSettings, Parser}; use clap::Parser;
use eyre::Result; use eyre::Result;
use tokio::{fs::File, io::AsyncWriteExt}; use tokio::{fs::File, io::AsyncWriteExt};
@ -9,7 +9,6 @@ use atuin_common::api::LoginRequest;
use rpassword::prompt_password; use rpassword::prompt_password;
#[derive(Parser)] #[derive(Parser)]
#[clap(setting(AppSettings::DeriveDisplayOrder))]
pub struct Cmd { pub struct Cmd {
#[clap(long, short)] #[clap(long, short)]
pub username: Option<String>, pub username: Option<String>,

View file

@ -1,11 +1,10 @@
use clap::{AppSettings, Parser}; use clap::Parser;
use eyre::Result; use eyre::Result;
use tokio::{fs::File, io::AsyncWriteExt}; use tokio::{fs::File, io::AsyncWriteExt};
use atuin_client::{api_client, settings::Settings}; use atuin_client::{api_client, settings::Settings};
#[derive(Parser)] #[derive(Parser)]
#[clap(setting(AppSettings::DeriveDisplayOrder))]
pub struct Cmd { pub struct Cmd {
#[clap(long, short)] #[clap(long, short)]
pub username: Option<String>, pub username: Option<String>,

View file

@ -13,19 +13,19 @@ mod init;
mod contributors; mod contributors;
#[derive(Subcommand)] #[derive(Subcommand)]
#[clap(infer_subcommands = true)] #[command(infer_subcommands = true)]
pub enum AtuinCmd { pub enum AtuinCmd {
#[cfg(feature = "client")] #[cfg(feature = "client")]
#[clap(flatten)] #[command(flatten)]
Client(client::Cmd), Client(client::Cmd),
/// Start an atuin server /// Start an atuin server
#[cfg(feature = "server")] #[cfg(feature = "server")]
#[clap(subcommand)] #[command(subcommand)]
Server(server::Cmd), Server(server::Cmd),
/// Output shell setup /// Output shell setup
#[clap(subcommand)] #[command(subcommand)]
Init(init::Cmd), Init(init::Cmd),
/// Generate a UUID /// Generate a UUID
@ -36,11 +36,11 @@ pub enum AtuinCmd {
/// Generate shell completions /// Generate shell completions
GenCompletions { GenCompletions {
/// Set the shell for generating completions /// Set the shell for generating completions
#[clap(long, short)] #[arg(long, short)]
shell: Shell, shell: Shell,
/// Set the output directory /// Set the output directory
#[clap(long, short)] #[arg(long, short)]
out_dir: Option<String>, out_dir: Option<String>,
}, },
} }

View file

@ -1,7 +1,7 @@
#![warn(clippy::pedantic, clippy::nursery)] #![warn(clippy::pedantic, clippy::nursery)]
#![allow(clippy::use_self, clippy::missing_const_for_fn)] // not 100% reliable #![allow(clippy::use_self, clippy::missing_const_for_fn)] // not 100% reliable
use clap::{AppSettings, Parser}; use clap::Parser;
use eyre::Result; use eyre::Result;
use command::AtuinCmd; use command::AtuinCmd;
@ -9,15 +9,25 @@ mod command;
const VERSION: &str = env!("CARGO_PKG_VERSION"); const VERSION: &str = env!("CARGO_PKG_VERSION");
static HELP_TEMPLATE: &str = "\
{before-help}{name} {version}
{author}
{about}
{usage-heading}
{usage}
{all-args}{after-help}";
/// Magical shell history /// Magical shell history
#[derive(Parser)] #[derive(Parser)]
#[clap( #[command(
author = "Ellie Huxtable <e@elm.sh>", author = "Ellie Huxtable <e@elm.sh>",
version = VERSION, version = VERSION,
global_setting(AppSettings::DeriveDisplayOrder), help_template(HELP_TEMPLATE),
)] )]
struct Atuin { struct Atuin {
#[clap(subcommand)] #[command(subcommand)]
atuin: AtuinCmd, atuin: AtuinCmd,
} }