aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConrad Ludgate <conradludgate@gmail.com>2022-10-18 09:50:22 +0100
committerGitHub <noreply@github.com>2022-10-18 09:50:22 +0100
commit5e2c438dabc74d7e87fad46c725501753a0a8a26 (patch)
treec6e1b3aea892e7150cd1d94bd13c68ee2efcea42
parentAdd message begging for help lol 🐢 (#569) (diff)
downloadatuin-5e2c438dabc74d7e87fad46c725501753a0a8a26.zip
Upgrade clap (#568)
Diffstat (limited to '')
-rw-r--r--Cargo.lock24
-rw-r--r--Cargo.toml4
-rw-r--r--src/command/client.rs8
-rw-r--r--src/command/client/history.rs16
-rw-r--r--src/command/client/import.rs2
-rw-r--r--src/command/client/search.rs20
-rw-r--r--src/command/client/stats.rs2
-rw-r--r--src/command/client/sync.rs4
-rw-r--r--src/command/client/sync/login.rs3
-rw-r--r--src/command/client/sync/register.rs3
-rw-r--r--src/command/mod.rs12
-rw-r--r--src/main.rs18
12 files changed, 58 insertions, 58 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 4b70f0ee..b9eb0d73 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -331,35 +331,33 @@ dependencies = [
[[package]]
name = "clap"
-version = "3.2.21"
+version = "4.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1ed5341b2301a26ab80be5cbdced622e80ed808483c52e45e3310a877d3b37d7"
+checksum = "6bf8832993da70a4c6d13c581f4463c2bdda27b9bf1c5498dc4365543abe6d6f"
dependencies = [
"atty",
"bitflags",
"clap_derive",
"clap_lex",
- "indexmap",
"once_cell",
"strsim",
"termcolor",
- "textwrap",
]
[[package]]
name = "clap_complete"
-version = "3.2.5"
+version = "4.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3f7a2e0a962c45ce25afce14220bc24f9dade0a1787f185cecf96bfba7847cd8"
+checksum = "11cba7abac9b56dfe2f035098cdb3a43946f276e6db83b72c4e692343f9aab9a"
dependencies = [
"clap",
]
[[package]]
name = "clap_derive"
-version = "3.2.18"
+version = "4.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
+checksum = "c42f169caba89a7d512b5418b09864543eeb4d497416c917d7137863bd2076ad"
dependencies = [
"heck",
"proc-macro-error",
@@ -370,9 +368,9 @@ dependencies = [
[[package]]
name = "clap_lex"
-version = "0.2.4"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
+checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [
"os_str_bytes",
]
@@ -1954,12 +1952,6 @@ dependencies = [
]
[[package]]
-name = "textwrap"
-version = "0.15.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
-
-[[package]]
name = "thiserror"
version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index e2397400..28c52c67 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -66,8 +66,8 @@ chrono-english = "0.1.4"
cli-table = { version = "0.4", default-features = false }
base64 = "0.13.0"
crossbeam-channel = "0.5.1"
-clap = { version = "3.1.18", features = ["derive"] }
-clap_complete = "3.1.4"
+clap = { version = "4.0.14", features = ["derive"] }
+clap_complete = "4.0.2"
fs-err = "2.7"
whoami = "1.1.2"
rpassword = "7.0"
diff --git a/src/command/client.rs b/src/command/client.rs
index 94148c09..f7b9d6fb 100644
--- a/src/command/client.rs
+++ b/src/command/client.rs
@@ -14,14 +14,14 @@ mod search;
mod stats;
#[derive(Subcommand)]
-#[clap(infer_subcommands = true)]
+#[command(infer_subcommands = true)]
pub enum Cmd {
/// Manipulate shell history
- #[clap(subcommand)]
+ #[command(subcommand)]
History(history::Cmd),
/// Import shell history from file
- #[clap(subcommand)]
+ #[command(subcommand)]
Import(import::Cmd),
/// Calculate statistics for your history
@@ -31,7 +31,7 @@ pub enum Cmd {
Search(search::Cmd),
#[cfg(feature = "sync")]
- #[clap(flatten)]
+ #[command(flatten)]
Sync(sync::Cmd),
}
diff --git a/src/command/client/history.rs b/src/command/client/history.rs
index 07f4b319..6a78adc9 100644
--- a/src/command/client/history.rs
+++ b/src/command/client/history.rs
@@ -20,7 +20,7 @@ use log::debug;
use super::search::format_duration;
#[derive(Subcommand)]
-#[clap(infer_subcommands = true)]
+#[command(infer_subcommands = true)]
pub enum Cmd {
/// Begins a new command in the history
Start { command: Vec<String> },
@@ -28,33 +28,33 @@ pub enum Cmd {
/// Finishes a new command in the history (adds time, exit code)
End {
id: String,
- #[clap(long, short)]
+ #[arg(long, short)]
exit: i64,
},
/// List all items in history
List {
- #[clap(long, short)]
+ #[arg(long, short)]
cwd: bool,
- #[clap(long, short)]
+ #[arg(long, short)]
session: bool,
- #[clap(long)]
+ #[arg(long)]
human: bool,
/// Show only the text of the command
- #[clap(long)]
+ #[arg(long)]
cmd_only: bool,
},
/// Get the last command ran
Last {
- #[clap(long)]
+ #[arg(long)]
human: bool,
/// Show only the text of the command
- #[clap(long)]
+ #[arg(long)]
cmd_only: bool,
},
}
diff --git a/src/command/client/import.rs b/src/command/client/import.rs
index 60fd536d..b0375acd 100644
--- a/src/command/client/import.rs
+++ b/src/command/client/import.rs
@@ -14,7 +14,7 @@ use atuin_client::{
};
#[derive(Parser)]
-#[clap(infer_subcommands = true)]
+#[command(infer_subcommands = true)]
pub enum Cmd {
/// Import history for the current shell
Auto,
diff --git a/src/command/client/search.rs b/src/command/client/search.rs
index 1cef1ffc..26026f34 100644
--- a/src/command/client/search.rs
+++ b/src/command/client/search.rs
@@ -18,45 +18,45 @@ pub use duration::format_duration;
#[derive(Parser)]
pub struct Cmd {
/// Filter search result by directory
- #[clap(long, short)]
+ #[arg(long, short)]
cwd: Option<String>,
/// Exclude directory from results
- #[clap(long = "exclude-cwd")]
+ #[arg(long = "exclude-cwd")]
exclude_cwd: Option<String>,
/// Filter search result by exit code
- #[clap(long, short)]
+ #[arg(long, short)]
exit: Option<i64>,
/// Exclude results with this exit code
- #[clap(long = "exclude-exit")]
+ #[arg(long = "exclude-exit")]
exclude_exit: Option<i64>,
/// Only include results added before this date
- #[clap(long, short)]
+ #[arg(long, short)]
before: Option<String>,
/// Only include results after this date
- #[clap(long)]
+ #[arg(long)]
after: Option<String>,
/// How many entries to return at most
- #[clap(long)]
+ #[arg(long)]
limit: Option<i64>,
/// Open interactive search UI
- #[clap(long, short)]
+ #[arg(long, short)]
interactive: bool,
/// Use human-readable formatting for time
- #[clap(long)]
+ #[arg(long)]
human: bool,
query: Vec<String>,
/// Show only the text of the command
- #[clap(long)]
+ #[arg(long)]
cmd_only: bool,
}
diff --git a/src/command/client/stats.rs b/src/command/client/stats.rs
index 157496de..a00eb369 100644
--- a/src/command/client/stats.rs
+++ b/src/command/client/stats.rs
@@ -13,7 +13,7 @@ use atuin_client::{
};
#[derive(Parser)]
-#[clap(infer_subcommands = true)]
+#[command(infer_subcommands = true)]
pub struct Cmd {
/// compute statistics for the specified period, leave blank for statistics since the beginning
period: Vec<String>,
diff --git a/src/command/client/sync.rs b/src/command/client/sync.rs
index af809f3e..51fcbf63 100644
--- a/src/command/client/sync.rs
+++ b/src/command/client/sync.rs
@@ -8,12 +8,12 @@ mod logout;
mod register;
#[derive(Subcommand)]
-#[clap(infer_subcommands = true)]
+#[command(infer_subcommands = true)]
pub enum Cmd {
/// Sync with the configured server
Sync {
/// Force re-download everything
- #[clap(long, short)]
+ #[arg(long, short)]
force: bool,
},
diff --git a/src/command/client/sync/login.rs b/src/command/client/sync/login.rs
index 29222563..333a1514 100644
--- a/src/command/client/sync/login.rs
+++ b/src/command/client/sync/login.rs
@@ -1,6 +1,6 @@
use std::io;
-use clap::{AppSettings, Parser};
+use clap::Parser;
use eyre::Result;
use tokio::{fs::File, io::AsyncWriteExt};
@@ -9,7 +9,6 @@ use atuin_common::api::LoginRequest;
use rpassword::prompt_password;
#[derive(Parser)]
-#[clap(setting(AppSettings::DeriveDisplayOrder))]
pub struct Cmd {
#[clap(long, short)]
pub username: Option<String>,
diff --git a/src/command/client/sync/register.rs b/src/command/client/sync/register.rs
index 2b5b9ced..6b51fac8 100644
--- a/src/command/client/sync/register.rs
+++ b/src/command/client/sync/register.rs
@@ -1,11 +1,10 @@
-use clap::{AppSettings, Parser};
+use clap::Parser;
use eyre::Result;
use tokio::{fs::File, io::AsyncWriteExt};
use atuin_client::{api_client, settings::Settings};
#[derive(Parser)]
-#[clap(setting(AppSettings::DeriveDisplayOrder))]
pub struct Cmd {
#[clap(long, short)]
pub username: Option<String>,
diff --git a/src/command/mod.rs b/src/command/mod.rs
index df6b66e9..038b24c8 100644
--- a/src/command/mod.rs
+++ b/src/command/mod.rs
@@ -13,19 +13,19 @@ mod init;
mod contributors;
#[derive(Subcommand)]
-#[clap(infer_subcommands = true)]
+#[command(infer_subcommands = true)]
pub enum AtuinCmd {
#[cfg(feature = "client")]
- #[clap(flatten)]
+ #[command(flatten)]
Client(client::Cmd),
/// Start an atuin server
#[cfg(feature = "server")]
- #[clap(subcommand)]
+ #[command(subcommand)]
Server(server::Cmd),
/// Output shell setup
- #[clap(subcommand)]
+ #[command(subcommand)]
Init(init::Cmd),
/// Generate a UUID
@@ -36,11 +36,11 @@ pub enum AtuinCmd {
/// Generate shell completions
GenCompletions {
/// Set the shell for generating completions
- #[clap(long, short)]
+ #[arg(long, short)]
shell: Shell,
/// Set the output directory
- #[clap(long, short)]
+ #[arg(long, short)]
out_dir: Option<String>,
},
}
diff --git a/src/main.rs b/src/main.rs
index 798f7a23..2f81f4fc 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,7 @@
#![warn(clippy::pedantic, clippy::nursery)]
#![allow(clippy::use_self, clippy::missing_const_for_fn)] // not 100% reliable
-use clap::{AppSettings, Parser};
+use clap::Parser;
use eyre::Result;
use command::AtuinCmd;
@@ -9,15 +9,25 @@ mod command;
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
#[derive(Parser)]
-#[clap(
+#[command(
author = "Ellie Huxtable <e@elm.sh>",
version = VERSION,
- global_setting(AppSettings::DeriveDisplayOrder),
+ help_template(HELP_TEMPLATE),
)]
struct Atuin {
- #[clap(subcommand)]
+ #[command(subcommand)]
atuin: AtuinCmd,
}