alf_tui 0.5.0

A smolderingly-nimble Rust TUI to rediscover your custom shell.
Documentation
//! CLI argument parsing and command handling.

pub mod config_cmd;
pub mod init;

use clap::{Parser, Subcommand};

/// Alias & Function CLI Searching Tool
#[derive(Debug, Parser)]
#[command(name = "alf")]
#[command(version, about, long_about = None, disable_help_subcommand = true)]
pub struct Cli {
   #[command(subcommand)]
   pub command: Option<Commands>,
}

/// Available subcommands
#[derive(Debug, Subcommand)]
pub enum Commands {
   /// Activate shell integration by printing the wrapper function
   Activate {
      /// Shell to generate the wrapper for (zsh, bash)
      shell: String,
   },

   /// Manage configuration
   Config {
      #[command(subcommand)]
      action: ConfigAction,
   },

   /// Initialize configuration (first-run setup)
   Init {
      /// Print shell integration wrapper for the given shell and exit
      #[arg(long, value_name = "SHELL")]
      print_shell_hook: Option<String>,
   },

   /// Launch the interactive TUI search interface with required query
   Search {
      /// Required search query to filter results on startup
      query: String,
   },
}

/// Configuration management actions
#[derive(Debug, Subcommand)]
pub enum ConfigAction {
   /// Add one or more shell source files to the configuration
   Add {
      /// Path(s) to the shell source file(s) to add
      #[arg(required = true, num_args = 1.., value_name = "PATH")]
      paths: Vec<String>,
   },

   /// Show current configuration
   Show,

   /// Edit configuration file
   Edit,

   /// Reset to default configuration
   Reset,
}

#[cfg(test)]
mod cli_tests;