Skip to content

Commit

Permalink
infer subcommands where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Dec 19, 2021
1 parent dffc5ba commit 8444fed
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 39 deletions.
9 changes: 3 additions & 6 deletions src/command/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -13,21 +13,19 @@ 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)]
exit: i64,
},

/// list all items in history
#[clap(aliases=&["l", "li", "lis"])]
List {
#[clap(long, short)]
cwd: bool,
Expand All @@ -44,7 +42,6 @@ pub enum Cmd {
},

/// get the last command ran
#[clap(aliases=&["la", "las"])]
Last {
#[clap(long)]
human: bool,
Expand Down
23 changes: 6 additions & 17 deletions src/command/import.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/command/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 3 additions & 5 deletions src/command/server.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
13 changes: 4 additions & 9 deletions src/command/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

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

Expand Down

0 comments on commit 8444fed

Please sign in to comment.