Skip to main content

trail/
cli.rs

1//! CLI argument definitions for Trail.
2//!
3//! Defines the `clap`-based command-line interface: `--cwd-file` (consumed by
4//! Phase 6's shell integration), `--config` (consumed by Phase 7's config
5//! loading), and an optional positional start path.
6
7use clap::Parser;
8use std::path::PathBuf;
9
10/// Trail — a terminal file manager.
11#[derive(Parser, Debug)]
12#[command(name = "trail", version = crate::version::LONG_VERSION, about = "A terminal file manager")]
13pub struct Cli {
14    /// Path to write the final working directory on normal exit.
15    ///
16    /// Used by shell wrapper functions to `cd` into the last-browsed
17    /// directory after Trail exits. If omitted, no file is written.
18    #[arg(long)]
19    pub cwd_file: Option<PathBuf>,
20
21    /// Path to a TOML configuration file.
22    ///
23    /// The path is remembered, so a later `trail` with no `--config` reloads
24    /// the same file. If nothing has ever been loaded, Trail uses its
25    /// built-in defaults.
26    #[arg(long)]
27    pub config: Option<PathBuf>,
28
29    /// Ignore the remembered `--config` file and use the built-in defaults.
30    ///
31    /// Affects this run only; the remembered path is left in place, so a
32    /// later bare `trail` picks it up again.
33    #[arg(long, conflicts_with = "config")]
34    pub no_config: bool,
35
36    /// Print every file and directory Trail uses, then exit.
37    ///
38    /// Reports the binary, config and data directories, the log file and any
39    /// shell wrappers found, each marked with whether it exists. The locations
40    /// are platform-dependent and not guessable, so this is what the uninstall
41    /// documentation and scripts point at.
42    #[arg(long)]
43    pub paths: bool,
44
45    /// Starting directory. Defaults to the current working directory.
46    #[arg(default_value = ".")]
47    pub start_path: PathBuf,
48}