use clap::{Parser, Subcommand, ValueEnum};
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(
author,
version,
about = "Alman is a command-line tool and TUI for managing shell aliases with intelligent suggestions based on your command history.",
long_about = "A powerful command-line tool and TUI for managing shell aliases with intelligent suggestions, analytics, and multi-shell support.",
disable_help_subcommand = true,
after_help = "EXAMPLES:
alman add --command \"git status\" gs
alman remove gs
alman change old-alias new-alias
alman list
alman get-suggestions -n 10
alman tui"
)]
pub struct Cli {
#[arg(short, long, value_name = "ALIAS_FILE_PATH", help = "Path to the alias file to use")]
pub alias_file_path: Option<PathBuf>,
#[command(subcommand)]
pub operation: Option<Operation>,
}
#[derive(Subcommand, Debug)]
pub enum Operation {
#[command(after_help = "EXAMPLE:
alman add --command \"git status\" gs")]
Add {
#[arg(short = 'c', long, help = "Command to associate with the alias")]
command: String,
alias: String,
},
#[command(after_help = "EXAMPLE:
alman remove gs")]
Remove {
alias: String,
},
#[command(after_help = "EXAMPLE:
alman list")]
List,
#[command(after_help = "EXAMPLE:
alman change old-alias new-alias")]
Change {
old_alias: String,
new_alias: String,
},
#[command(after_help = "EXAMPLE:
alman get-suggestions -n 10")]
GetSuggestions {
#[arg(short = 'n', long, help = "Number of suggestions to display")]
num: Option<usize>,
},
#[command(after_help = "EXAMPLE:
alman delete-suggestion gs")]
DeleteSuggestion {
alias: String,
},
#[command(after_help = "EXAMPLE:
alman tui")]
Tui,
#[command(hide = true)]
Init {
#[arg(value_enum, help = "Shell type to initialize (bash, zsh, fish, posix)")]
shell: InitShell,
},
#[command(hide = true)]
InitData,
}
#[derive(ValueEnum, Clone, Debug)]
pub enum InitShell {
Bash,
Zsh,
Fish,
#[clap(alias = "ksh")]
Posix,
}