|
| 1 | +//! CLI styling and formatting. |
| 2 | +//! |
| 3 | +//! Defines ANSI colors and formatting for the CLI help output. |
| 4 | +
|
| 5 | +use clap::builder::styling::{AnsiColor, Effects, Styles}; |
| 6 | + |
| 7 | +/// Cortex CLI styled help theme. |
| 8 | +/// |
| 9 | +/// Uses a modern color scheme with cyan accents for a beautiful terminal experience. |
| 10 | +pub fn get_styles() -> Styles { |
| 11 | + Styles::styled() |
| 12 | + // Headers (USAGE, COMMANDS, OPTIONS) - Bold cyan |
| 13 | + .header(AnsiColor::Cyan.on_default() | Effects::BOLD) |
| 14 | + // Usage line - Green |
| 15 | + .usage(AnsiColor::Green.on_default() | Effects::BOLD) |
| 16 | + // Literals (command names, flag names) - Bold green |
| 17 | + .literal(AnsiColor::Green.on_default() | Effects::BOLD) |
| 18 | + // Placeholders (<VALUE>, [ARGS]) - Yellow |
| 19 | + .placeholder(AnsiColor::Yellow.on_default()) |
| 20 | + // Errors - Bold red |
| 21 | + .error(AnsiColor::Red.on_default() | Effects::BOLD) |
| 22 | + // Valid values - Cyan |
| 23 | + .valid(AnsiColor::Cyan.on_default()) |
| 24 | + // Invalid values - Yellow |
| 25 | + .invalid(AnsiColor::Yellow.on_default()) |
| 26 | +} |
| 27 | + |
| 28 | +/// After-help section with environment variables documentation. |
| 29 | +pub const AFTER_HELP: &str = color_print::cstr!( |
| 30 | + r#" |
| 31 | +<cyan,bold>ENVIRONMENT VARIABLES:</> |
| 32 | + <green,bold>CORTEX_HOME</> Override config directory (default: ~/.config/cortex) |
| 33 | + <green,bold>CORTEX_API_KEY</> API key (alternative to --with-api-key) |
| 34 | + <green,bold>CORTEX_MODEL</> Default model (alternative to --model) |
| 35 | + <green,bold>CORTEX_LOG_LEVEL</> Log verbosity (error, warn, info, debug, trace) |
| 36 | + <green,bold>NO_COLOR</> Disable colored output (set to '1' or 'true') |
| 37 | + <green,bold>VISUAL</> Editor for /edit command (fallback: EDITOR) |
| 38 | + <green,bold>EDITOR</> Fallback editor if VISUAL is not set |
| 39 | +
|
| 40 | +<cyan,bold>PATHS:</> |
| 41 | + <green,bold>Config file</> ~/.config/cortex/config.toml |
| 42 | + <green,bold>Sessions</> ~/.local/share/cortex/sessions/ |
| 43 | + <green,bold>Logs</> ~/.cache/cortex/logs/ |
| 44 | + <green,bold>Agents</> ~/.cortex/agents/ (personal), .cortex/agents/ (project) |
| 45 | +
|
| 46 | +<cyan,bold>QUICK START:</> |
| 47 | + <yellow>cortex</> Start interactive TUI |
| 48 | + <yellow>cortex</> <dim>"fix the bug"</> Start TUI with initial prompt |
| 49 | + <yellow>cortex run</> <dim>"explain this"</> Non-interactive single request |
| 50 | + <yellow>cortex exec</> <dim>"run tests"</> Headless execution for CI/CD |
| 51 | + <yellow>cortex resume --last</> Continue most recent session |
| 52 | +
|
| 53 | +<cyan,bold>LEARN MORE:</> |
| 54 | + Documentation: <blue,underline>https://docs.cortex.foundation</> |
| 55 | + Report issues: <blue,underline>https://github.com/CortexLM/cortex-cli/issues</> |
| 56 | +"# |
| 57 | +); |
| 58 | + |
| 59 | +/// Before-help section with ASCII art banner. |
| 60 | +pub const BEFORE_HELP: &str = color_print::cstr!( |
| 61 | + r#" |
| 62 | +<cyan,bold> ██████╗ ██████╗ ██████╗ ████████╗███████╗██╗ ██╗</> |
| 63 | +<cyan,bold> ██╔════╝██╔═══██╗██╔══██╗╚══██╔══╝██╔════╝╚██╗██╔╝</> |
| 64 | +<cyan,bold> ██║ ██║ ██║██████╔╝ ██║ █████╗ ╚███╔╝ </> |
| 65 | +<cyan,bold> ██║ ██║ ██║██╔══██╗ ██║ ██╔══╝ ██╔██╗ </> |
| 66 | +<cyan,bold> ╚██████╗╚██████╔╝██║ ██║ ██║ ███████╗██╔╝ ██╗</> |
| 67 | +<cyan,bold> ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝</> |
| 68 | +<dim> AI-Powered Coding Agent</> |
| 69 | +"# |
| 70 | +); |
| 71 | + |
| 72 | +/// Command category display names for styled help output. |
| 73 | +pub mod categories { |
| 74 | + pub const EXECUTION: &str = "Execution Modes"; |
| 75 | + pub const SESSION: &str = "Session Management"; |
| 76 | + pub const AUTH: &str = "Authentication"; |
| 77 | + pub const EXTENSION: &str = "Extensibility"; |
| 78 | + pub const CONFIG: &str = "Configuration"; |
| 79 | + pub const UTILITIES: &str = "Utilities"; |
| 80 | + pub const ADVANCED: &str = "Advanced"; |
| 81 | +} |
0 commit comments