infer subcommands where appropriate

This commit is contained in:
Conrad Ludgate 2021-12-11 07:40:42 +00:00
parent dffc5ba9e8
commit 8444fedd29
5 changed files with 18 additions and 39 deletions

View File

@ -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,

View File

@ -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(

View File

@ -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,

View File

@ -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)]

View File

@ -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> },
}