use clap::{Parser, Subcommand, ValueEnum};
use std::path::PathBuf;
#[derive(Parser)]
#[command(name = "ls-plus")] #[command(about = "Enhanced ls command with modern features")] #[command(version)] pub struct Cli {
#[arg(default_value = ".")]
pub path: PathBuf,
#[arg(short = 'a', long)]
pub all: bool,
#[arg(short = 'l', long)]
pub long: bool,
#[arg(long)]
pub human_readable: bool,
#[arg(short = 't', long)]
pub time: bool,
#[arg(short = 'r', long)]
pub reverse: bool,
#[arg(long)]
pub directories_first: bool,
#[arg(short = 'L', long)]
pub follow_links: bool,
#[arg(long)]
pub icons: bool,
#[arg(long, value_enum, default_value_t = ColorOption::Auto)]
pub color: ColorOption,
#[arg(long, value_enum, default_value_t = FormatOption::Default)]
pub format: FormatOption,
#[arg(long, value_enum)]
pub file_type: Option<FileTypeFilter>,
#[arg(long)]
pub max_depth: Option<usize>,
#[arg(long)]
pub git: bool,
#[command(subcommand)]
pub command: Option<Commands>,
}
#[derive(Subcommand)]
pub enum Commands {
Config {
#[command(subcommand)]
action: ConfigAction,
},
Tree {
#[arg(default_value = ".")]
path: PathBuf,
#[arg(short = 'd', long)]
max_depth: Option<usize>,
#[arg(short = 'a', long)]
all: bool,
},
Find {
pattern: String,
#[arg(default_value = ".")]
path: PathBuf,
#[arg(short = 'i', long)]
ignore_case: bool,
#[arg(short = 't', long, value_enum)]
file_type: Option<FileTypeFilter>,
},
Describe {
#[command(subcommand)]
action: DescribeAction,
},
}
#[derive(Subcommand)]
pub enum ConfigAction {
Show,
Set {
key: String,
value: String,
},
Reset,
Edit,
}
#[derive(Subcommand)]
pub enum DescribeAction {
Set {
description: String,
#[arg(default_value = ".")]
path: PathBuf,
},
Get {
#[arg(default_value = ".")]
path: PathBuf,
},
Remove {
#[arg(default_value = ".")]
path: PathBuf,
},
List,
Search {
query: String,
},
Cleanup,
}
#[derive(Clone, Debug, ValueEnum, serde::Serialize, serde::Deserialize)]
pub enum ColorOption {
Always,
Never,
Auto,
}
#[derive(Clone, Debug, ValueEnum, serde::Serialize, serde::Deserialize)]
pub enum FormatOption {
Default,
Long,
Tree,
Grid,
Json,
}
#[derive(Clone, Debug, ValueEnum)]
pub enum FileTypeFilter {
File,
Dir,
Link,
Exec,
Image,
Audio,
Video,
Archive,
Document,
}
impl Default for ColorOption {
fn default() -> Self {
ColorOption::Auto
}
}
impl Default for FormatOption {
fn default() -> Self {
FormatOption::Default
}
}