sqry_cli/args/headings.rs
1//! Help heading constants and taxonomy helpers for sqry CLI
2//!
3//! This module provides a single source of truth for help text organization,
4//! ensuring consistent grouping across all commands and subcommands.
5//!
6//! Tested with clap 4.5.x - heading behavior may change in future versions.
7
8use clap::Command;
9
10// ===== Phase 1 Headings (Core Taxonomy) =====
11
12/// Common options that appear across all commands
13pub const COMMON_OPTIONS: &str = "Common Options";
14
15/// Match behavior configuration (case, exact, regex)
16pub const MATCH_BEHAVIOUR: &str = "Match Behaviour";
17
18/// Search mode selection (fuzzy, semantic, text)
19pub const SEARCH_MODES: &str = "Search Modes";
20
21/// Fuzzy search configuration
22pub const SEARCH_MODES_FUZZY: &str = "Search Modes — Fuzzy";
23
24/// Output formatting and presentation
25pub const OUTPUT_CONTROL: &str = "Output Control";
26
27/// File filtering and traversal
28pub const FILE_FILTERING: &str = "File Filtering & Traversal";
29
30/// Index management operations
31///
32/// Reserved for Phase 2.2+ command grouping of `index`, `update`, and `cache`.
33/// Suppress `dead_code` lint until integrated in root help layout.
34#[allow(dead_code)]
35pub const INDEX_MANAGEMENT: &str = "Index Management";
36
37// ===== Phase 1.5 Headings (Utilities) =====
38
39/// Utilities grouping for batch and completions
40pub const UTILITIES: &str = "Utilities";
41
42/// Batch command input sources
43pub const BATCH_INPUTS: &str = "Batch Input";
44
45/// Batch command output targets
46pub const BATCH_OUTPUT_TARGETS: &str = "Batch Output Targets";
47
48/// Batch session control and resilience
49pub const BATCH_SESSION_CONTROL: &str = "Session Control & Resilience";
50
51/// Completions shell targets
52pub const COMPLETIONS_SHELL_TARGETS: &str = "Shell Targets";
53
54// ===== Phase 2.2+ Headings (Core & Advanced Commands) =====
55
56/// Index command input configuration
57pub const INDEX_INPUT: &str = "Index Input";
58
59/// Index build configuration options
60pub const INDEX_CONFIGURATION: &str = "Index Configuration";
61
62/// Performance tuning for indexing and queries
63pub const PERFORMANCE_TUNING: &str = "Performance Tuning";
64
65/// Advanced configuration (cache dirs, etc.)
66pub const ADVANCED_CONFIGURATION: &str = "Advanced Configuration";
67
68/// Plugin selection and cost-tier controls.
69pub const PLUGIN_SELECTION: &str = "Plugin Selection";
70
71/// Query input specification
72pub const QUERY_INPUT: &str = "Query Input";
73
74/// Performance and debugging options
75pub const PERFORMANCE_DEBUGGING: &str = "Performance & Debugging";
76
77/// Search input specification
78pub const SEARCH_INPUT: &str = "Search Input";
79
80/// Watch command configuration
81pub const WATCH_CONFIGURATION: &str = "Watch Configuration";
82
83/// Update command configuration
84pub const UPDATE_CONFIGURATION: &str = "Update Configuration";
85
86/// Repair command options
87pub const REPAIR_OPTIONS: &str = "Repair Options";
88
89/// Shell command configuration
90pub const SHELL_CONFIGURATION: &str = "Shell Configuration";
91
92// ===== Phase 3 Headings (Specialized Commands) =====
93
94/// Visualization input specification
95pub const VISUALIZATION_INPUT: &str = "Visualization Input";
96
97/// Diagram configuration and formatting
98pub const DIAGRAM_CONFIGURATION: &str = "Diagram Configuration";
99
100/// Graph traversal control
101pub const TRAVERSAL_CONTROL: &str = "Traversal Control";
102
103/// Cache input paths
104pub const CACHE_INPUT: &str = "Cache Input";
105
106/// Config command input specification
107pub const CONFIG_INPUT: &str = "Config Input";
108
109/// Safety controls for destructive operations
110pub const SAFETY_CONTROL: &str = "Safety Control";
111
112/// Workspace input paths
113pub const WORKSPACE_INPUT: &str = "Workspace Input";
114
115/// Workspace configuration options
116pub const WORKSPACE_CONFIGURATION: &str = "Workspace Configuration";
117
118// ===== Phase 4 Headings (Graph Command) =====
119
120/// Graph command root-level configuration
121pub const GRAPH_CONFIGURATION: &str = "Graph Configuration";
122
123// ===== Query Persistence Headings (P2-11/P2-17) =====
124
125/// Alias command input specification
126pub const ALIAS_INPUT: &str = "Alias Input";
127
128/// Alias command configuration options
129pub const ALIAS_CONFIGURATION: &str = "Alias Configuration";
130
131/// History command input specification
132pub const HISTORY_INPUT: &str = "History Input";
133
134/// History command configuration options
135pub const HISTORY_CONFIGURATION: &str = "History Configuration";
136
137/// Query persistence options (for --save-as on query/search)
138pub const PERSISTENCE_OPTIONS: &str = "Persistence Options";
139
140// ===== Natural Language Headings =====
141
142/// Natural language query input
143pub const NL_INPUT: &str = "Query Input";
144
145/// Natural language translation configuration
146pub const NL_CONFIGURATION: &str = "Translation Configuration";
147
148/// Graph analysis input targets
149pub const GRAPH_ANALYSIS_INPUT: &str = "Analysis Input";
150
151/// Graph filtering and constraints
152pub const GRAPH_FILTERING: &str = "Filtering & Constraints";
153
154/// Graph analysis options
155pub const GRAPH_ANALYSIS_OPTIONS: &str = "Analysis Options";
156
157/// Graph output customization
158pub const GRAPH_OUTPUT_OPTIONS: &str = "Output Options";
159
160/// Security limits for query execution (CD Static Analysis)
161pub const SECURITY_LIMITS: &str = "Security Limits";
162
163// ===== Local Uses and Insights Headings =====
164
165/// Insights command configuration
166pub const INSIGHTS_CONFIGURATION: &str = "Insights Configuration";
167
168/// Insights output options
169pub const INSIGHTS_OUTPUT: &str = "Output Options";
170
171// ===== Code Analysis Headings (Duplicates, Cycles, Unused) =====
172
173/// Duplicate detection options
174pub const DUPLICATE_OPTIONS: &str = "Duplicate Detection";
175
176/// Cycle detection options
177pub const CYCLE_OPTIONS: &str = "Cycle Detection";
178
179/// Unused code detection options
180pub const UNUSED_OPTIONS: &str = "Unused Code Detection";
181
182/// Export format options
183pub const EXPORT_OPTIONS: &str = "Export Options";
184
185// ===== Helper Functions =====
186
187/// Apply root-level command layout by setting subcommand headings
188///
189/// This function mutates the root `Command` to assign the `UTILITIES` heading
190/// to utility subcommands (batch, completions) while preserving existing
191/// search workflow headings.
192///
193/// # Arguments
194/// * `cmd` - The root command (typically from `Cli::command()`)
195///
196/// # Returns
197/// The mutated command with updated subcommand headings
198#[must_use]
199pub fn apply_root_layout(cmd: Command) -> Command {
200 cmd.mut_subcommand("batch", |sub| sub.next_help_heading(UTILITIES))
201 .mut_subcommand("completions", |sub| sub.next_help_heading(UTILITIES))
202}
203
204/// Normalize command for deterministic help output in tests
205///
206/// Applies consistent ordering and formatting to make help snapshots
207/// reproducible across environments.
208///
209/// # Arguments
210/// * `cmd` - The command to normalize
211///
212/// # Returns
213/// The normalized command
214#[must_use]
215pub fn normalize(cmd: Command) -> Command {
216 // Currently a pass-through; future phases may enforce display_order
217 cmd
218}