1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//! Command-line argument definitions.
use std::path::PathBuf;
use clap::{Parser, ValueEnum};
/// A terminal Markdown browser.
#[derive(Debug, Parser)]
#[command(
name = "perga",
version,
about = "A terminal Markdown browser",
long_about = None,
disable_version_flag = false
)]
pub struct Cli {
/// File or directory to open. A file opens that file with its parent
/// directory as the vault root. A directory opens it as the vault root.
pub path: Option<PathBuf>,
/// Use this config file instead of the default location.
#[arg(short = 'c', long, value_name = "FILE")]
pub config: Option<PathBuf>,
/// Ignore all config files and use built-in defaults.
#[arg(long)]
pub no_config: bool,
/// Override the configured theme.
#[arg(short = 't', long, value_name = "NAME")]
pub theme: Option<String>,
/// Initial sidebar mode.
#[arg(long, value_name = "MODE")]
pub sidebar: Option<SidebarModeArg>,
/// Start with the sidebar hidden.
#[arg(long)]
pub no_sidebar: bool,
/// Show non-Markdown files in the tree.
#[arg(short = 'a', long)]
pub all: bool,
/// Do not respect .gitignore.
#[arg(long)]
pub no_gitignore: bool,
/// Hard-wrap the document at this width (0 fits the viewport).
#[arg(short = 'w', long, value_name = "COLUMNS")]
pub wrap: Option<u16>,
/// Render the file to stdout with ANSI styling and exit.
#[arg(short = 'p', long)]
pub print: bool,
/// Validate config and theme files, print warnings, and exit.
#[arg(long)]
pub check_config: bool,
/// Print the default configuration to stdout.
#[arg(long)]
pub generate_config: bool,
/// Print shell completions to stdout.
#[arg(long, value_name = "SHELL")]
pub generate_completions: Option<Shell>,
/// Print the man page to stdout.
#[arg(long)]
pub generate_man: bool,
/// Do not restore or save the session for this run.
#[arg(long)]
pub no_session: bool,
/// Start with mouse capture disabled.
#[arg(long)]
pub no_mouse: bool,
/// Write debug logs to this file.
#[arg(long, value_name = "FILE")]
pub log: Option<PathBuf>,
/// Panic immediately after the terminal is set up.
///
/// Hidden: this exists so the panic hook's terminal restoration can be
/// exercised for real, which is not something an automated test can do
/// without a pseudo-terminal. See `docs/decisions.md`.
#[arg(long, hide = true)]
pub debug_panic: bool,
}
/// The sidebar mode selected by `--sidebar`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum SidebarModeArg {
Files,
Search,
Outline,
Links,
}
/// Shells for which completions can be generated.
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum Shell {
Bash,
Zsh,
Fish,
}