coding_tools/cli/
ct_view.rs1use std::path::PathBuf;
8
9use clap::Parser;
10
11use crate::explain::Format;
12use crate::pattern;
13use crate::pulse::HeartbeatOpts;
14
15#[derive(Parser, Debug)]
16#[command(
17 name = "ct-view",
18 version,
19 about = "Show a file's lines by range, or the regions around a pattern with context.",
20 long_about = "ct-view is a focused, bounded reader for a single file (also reachable as \
21 `ct view`): print a line range with --range, or the windows around a \
22 --match pattern with --context lines, rather than dumping the whole file. \
23 See `ct-view --explain` for agent-oriented documentation."
24)]
25pub struct Cli {
26 pub path: PathBuf,
28
29 #[arg(long)]
31 pub range: Option<String>,
32
33 #[arg(long = "match")]
35 pub pattern: Option<String>,
36
37 #[arg(long, value_enum)]
39 pub mode: Option<pattern::Mode>,
40
41 #[arg(long, short = 'C', default_value_t = 2)]
43 pub context: usize,
44
45 #[arg(long)]
47 pub limit: Option<usize>,
48
49 #[arg(long, value_name = "SECS")]
51 pub timeout: Option<f64>,
52
53 #[command(flatten)]
54 pub heartbeat: HeartbeatOpts,
55
56 #[arg(long)]
58 pub plain: bool,
59
60 #[arg(long)]
62 pub json: bool,
63
64 #[arg(long)]
66 pub json_pretty: bool,
67
68 #[arg(long, value_enum, num_args = 0..=1, default_missing_value = "md")]
70 pub explain: Option<Format>,
71}