updated CLI

This commit is contained in:
thePR0M3TH3AN
2025-05-15 16:37:59 -04:00
parent 84df958978
commit a38f613a79
13 changed files with 443 additions and 57 deletions

View File

@@ -1,15 +1,36 @@
// src/cli.rs
use std::path::PathBuf;
use clap::{Parser, Subcommand};
pub mod link;
pub mod coll;
pub mod view;
pub mod state;
pub mod task;
pub mod remind;
pub mod annotate;
pub mod version;
pub mod event;
use clap::{Parser, Subcommand, ArgEnum, Args, CommandFactory};
use clap_complete::Shell;
/// Output format for commands.
#[derive(ArgEnum, Clone, Copy, Debug)]
pub enum Format {
Text,
Json,
}
/// Marlin metadata-driven file explorer (CLI utilities)
#[derive(Parser, Debug)]
#[command(author, version, about)]
#[command(author, version, about, propagate_version = true)]
pub struct Cli {
/// Enable debug logging and extra output
#[arg(long)]
pub verbose: bool,
/// Output format (text or JSON)
#[arg(long, default_value = "text", value_enum, global = true)]
pub format: Format,
#[command(subcommand)]
pub command: Commands,
}
@@ -21,12 +42,15 @@ pub enum Commands {
/// Scan one or more directories and populate the file index
Scan {
paths: Vec<PathBuf>,
/// Directories to scan (defaults to cwd)
paths: Vec<std::path::PathBuf>,
},
/// Tag files matching a glob pattern (hierarchical tags use `/`)
Tag {
/// Glob or path pattern
pattern: String,
/// Hierarchical tag name (`foo/bar`)
tag_path: String,
},
@@ -46,14 +70,57 @@ pub enum Commands {
/// Create a timestamped backup of the database
Backup,
/// Restore from a backup file (over-writes current DB)
/// Restore from a backup file (overwrites current DB)
Restore {
backup_path: PathBuf,
backup_path: std::path::PathBuf,
},
/// Generate shell completions (hidden)
#[command(hide = true)]
Completions {
#[arg(value_enum)]
shell: Shell,
},
/// File-to-file links
#[command(subcommand)]
Link { cmd: link::LinkCmd },
/// Collections (groups) of files
#[command(subcommand)]
Coll { cmd: coll::CollCmd },
/// Smart views (saved queries)
#[command(subcommand)]
View { cmd: view::ViewCmd },
/// Workflow states on files
#[command(subcommand)]
State { cmd: state::StateCmd },
/// TODO/tasks management
#[command(subcommand)]
Task { cmd: task::TaskCmd },
/// Reminders on files
#[command(subcommand)]
Remind { cmd: remind::RemindCmd },
/// File annotations and highlights
#[command(subcommand)]
Annotate { cmd: annotate::AnnotateCmd },
/// Version diffs
#[command(subcommand)]
Version { cmd: version::VersionCmd },
/// Calendar events & timelines
#[command(subcommand)]
Event { cmd: event::EventCmd },
}
#[derive(Subcommand, Debug)]
pub enum AttrCmd {
Set { pattern: String, key: String, value: String },
Ls { path: PathBuf },
Ls { path: std::path::PathBuf },
}