use crate::{ action::{Action, Actions}, cable::{self, Cable}, channels::prototypes::{ChannelPrototype, Template}, cli::args::{Cli, Command}, config::{ DEFAULT_PREVIEW_SIZE, KeyBindings, get_config_dir, get_data_dir, merge_bindings, ui::{BorderType, Padding}, }, errors::cli_parsing_error_exit, event::Key, screen::layout::Orientation, utils::paths::expand_tilde, }; use anyhow::{Result, anyhow}; use clap::CommandFactory; use clap::error::ErrorKind; use colored::Colorize; use rustc_hash::FxHashMap; use std::{ path::{Path, PathBuf}, str::FromStr, }; use tracing::debug; pub mod args; /// # CLI Use Cases /// /// The CLI interface supports two primary use cases: /// /// ## 1. Channel-based mode (channel is specified) /// When a channel is provided, the CLI operates in **override mode**: /// - The channel provides the base configuration (source, preview, UI settings) /// - All CLI flags act as **overrides** to the channel's defaults /// - Most restrictions are enforced at the clap level using `conflicts_with` /// - Templates and keybindings are validated after clap parsing /// - More permissive - allows any combination of flags as they override channel defaults /// /// ## 2. Ad-hoc mode (no channel specified) /// When no channel is provided, the CLI creates an **ad-hoc channel**: /// - Stricter validation rules apply for interdependent flags /// - `--preview-*` flags require `--preview-command` to be set /// - `--source-*` flags require `--source-command` to be set /// - This ensures the ad-hoc channel has all necessary components to function /// /// The validation logic in `post_process()` enforces these constraints for ad-hoc mode /// while allowing full flexibility in channel-based mode. #[allow(clippy::struct_excessive_bools)] #[derive(Debug, Clone)] pub struct PostProcessedCli { // Channel and source configuration pub channel: Option, pub source_command_override: Option