summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConrad Ludgate <conradludgate@gmail.com>2021-12-11 07:40:42 +0000
committerConrad Ludgate <conradludgate@gmail.com>2021-12-19 10:08:34 +0000
commit8444fedd29bf185f481349abbf8ac53cd62739bc (patch)
tree6a46ada193fb01f7b279e547c4cc9b4e2a313c47
parentdffc5ba9e8bbea962fa3bf7d72884f9a3d64a91d (diff)
infer subcommands where appropriateclap3
-rw-r--r--src/command/history.rs9
-rw-r--r--src/command/import.rs23
-rw-r--r--src/command/init.rs4
-rw-r--r--src/command/server.rs8
-rw-r--r--src/command/stats.rs13
5 files changed, 18 insertions, 39 deletions
diff --git a/src/command/history.rs b/src/command/history.rs
index 4087c7c5..3066e79e 100644
--- a/src/command/history.rs
+++ b/src/command/history.rs
@@ -2,7 +2,7 @@ use std::env;
use std::io::Write;
use std::time::Duration;
-use clap::Subcommand;
+use clap::{AppSettings::InferSubcommands, Subcommand};
use eyre::Result;
use tabwriter::TabWriter;
@@ -13,13 +13,12 @@ use atuin_client::sync;
#[derive(Subcommand)]
#[clap(aliases = &["h", "hi", "his", "hist", "histo", "histor"])]
+#[clap(setting(InferSubcommands))]
pub enum Cmd {
- /// "begins a new command in the history
- #[clap(aliases=&["s", "st", "sta", "star"])]
+ /// begins a new command in the history
Start { command: Vec<String> },
/// finishes a new command in the history (adds time, exit code)
- #[clap(aliases=&["e", "en"])]
End {
id: String,
#[clap(long, short)]
@@ -27,7 +26,6 @@ pub enum Cmd {
},
/// list all items in history
- #[clap(aliases=&["l", "li", "lis"])]
List {
#[clap(long, short)]
cwd: bool,
@@ -44,7 +42,6 @@ pub enum Cmd {
},
/// get the last command ran
- #[clap(aliases=&["la", "las"])]
Last {
#[clap(long)]
human: bool,
diff --git a/src/command/import.rs b/src/command/import.rs
index 96f29767..46713d92 100644
--- a/src/command/import.rs
+++ b/src/command/import.rs
@@ -1,6 +1,6 @@
use std::{env, path::PathBuf};
-use clap::Subcommand;
+use clap::{AppSettings::InferSubcommands, Subcommand};
use eyre::{eyre, Result};
use atuin_client::import::{bash::Bash, fish::Fish, zsh::Zsh};
@@ -9,29 +9,18 @@ use atuin_client::{history::History, import::resh::Resh};
use indicatif::ProgressBar;
#[derive(Subcommand)]
+#[clap(setting(InferSubcommands))]
pub enum Cmd {
- #[clap(
- about="import history for the current shell",
- aliases=&["a", "au", "aut"],
- )]
+ /// import history for the current shell
Auto,
- #[clap(
- about="import history from the zsh history file",
- aliases=&["z", "zs"],
- )]
+ /// import history from the zsh history file
Zsh,
- #[clap(
- about="import history from the bash history file",
- aliases=&["b", "ba", "bas"],
- )]
+ /// import history from the bash history file
Bash,
- #[clap(
- about="import history from the resh history file",
- aliases=&["r", "re", "res"],
- )]
+ /// import history from the resh history file
Resh,
#[clap(
diff --git a/src/command/init.rs b/src/command/init.rs
index 7bfe4edc..0b0d42c0 100644
--- a/src/command/init.rs
+++ b/src/command/init.rs
@@ -2,9 +2,9 @@ use clap::Parser;
#[derive(Parser)]
pub enum Cmd {
- #[clap(about = "zsh setup")]
+ /// zsh setup
Zsh,
- #[clap(about = "bash setup")]
+ /// bash setup
Bash,
#[structopt(about = "fish setup")]
Fish,
diff --git a/src/command/server.rs b/src/command/server.rs
index 1b662781..4c1e4175 100644
--- a/src/command/server.rs
+++ b/src/command/server.rs
@@ -1,15 +1,13 @@
-use clap::Subcommand;
+use clap::{AppSettings::InferSubcommands, Subcommand};
use eyre::Result;
use atuin_server::launch;
use atuin_server::settings::Settings;
#[derive(Subcommand)]
+#[clap(setting(InferSubcommands))]
pub enum Cmd {
- #[clap(
- about="starts the server",
- aliases=&["s", "st", "sta", "star"],
- )]
+ /// starts the server
Start {
/// specify the host address to bind
#[clap(long, short)]
diff --git a/src/command/stats.rs b/src/command/stats.rs
index 0b7b6671..745de93c 100644
--- a/src/command/stats.rs
+++ b/src/command/stats.rs
@@ -4,7 +4,7 @@ use chrono::prelude::*;
use chrono::Duration;
use chrono_english::parse_date_string;
-use clap::Subcommand;
+use clap::{AppSettings::InferSubcommands, Subcommand};
use cli_table::{format::Justify, print_stdout, Cell, Style, Table};
use eyre::{eyre, Result};
@@ -13,17 +13,12 @@ use atuin_client::history::History;
use atuin_client::settings::Settings;
#[derive(Subcommand)]
+#[clap(setting(InferSubcommands))]
pub enum Cmd {
- #[clap(
- about="compute statistics for all of time",
- aliases=&["d", "da"],
- )]
+ /// compute statistics for all of time
All,
- #[clap(
- about="compute statistics for a single day",
- aliases=&["d", "da"],
- )]
+ /// compute statistics for a single day
Day { words: Vec<String> },
}