Skip to main content

alf/cli/
mod.rs

1//! CLI argument parsing and command handling.
2
3pub mod config_cmd;
4pub mod init;
5
6use clap::{Parser, Subcommand};
7
8/// Alias & Function CLI Searching Tool
9#[derive(Debug, Parser)]
10#[command(name = "alf")]
11#[command(version, about, long_about = None, disable_help_subcommand = true)]
12pub struct Cli {
13   #[command(subcommand)]
14   pub command: Option<Commands>,
15}
16
17/// Available subcommands
18#[derive(Debug, Subcommand)]
19pub enum Commands {
20   /// Activate shell integration by printing the wrapper function
21   Activate {
22      /// Shell to generate the wrapper for (zsh, bash)
23      shell: String,
24   },
25
26   /// Manage configuration
27   Config {
28      #[command(subcommand)]
29      action: ConfigAction,
30   },
31
32   /// Initialize configuration (first-run setup)
33   Init {
34      /// Print shell integration wrapper for the given shell and exit
35      #[arg(long, value_name = "SHELL")]
36      print_shell_hook: Option<String>,
37   },
38
39   /// Launch the interactive TUI search interface with required query
40   Search {
41      /// Required search query to filter results on startup
42      query: String,
43   },
44}
45
46/// Configuration management actions
47#[derive(Debug, Subcommand)]
48pub enum ConfigAction {
49   /// Add one or more shell source files to the configuration
50   Add {
51      /// Path(s) to the shell source file(s) to add
52      #[arg(required = true, num_args = 1.., value_name = "PATH")]
53      paths: Vec<String>,
54   },
55
56   /// Show current configuration
57   Show,
58
59   /// Edit configuration file
60   Edit,
61
62   /// Reset to default configuration
63   Reset,
64}
65
66#[cfg(test)]
67mod cli_tests;