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/// Query input specification
69pub const QUERY_INPUT: &str = "Query Input";
70
71/// Performance and debugging options
72pub const PERFORMANCE_DEBUGGING: &str = "Performance & Debugging";
73
74/// Search input specification
75pub const SEARCH_INPUT: &str = "Search Input";
76
77/// Watch command configuration
78pub const WATCH_CONFIGURATION: &str = "Watch Configuration";
79
80/// Update command configuration
81pub const UPDATE_CONFIGURATION: &str = "Update Configuration";
82
83/// Repair command options
84pub const REPAIR_OPTIONS: &str = "Repair Options";
85
86/// Shell command configuration
87pub const SHELL_CONFIGURATION: &str = "Shell Configuration";
88
89// ===== Phase 3 Headings (Specialized Commands) =====
90
91/// Visualization input specification
92pub const VISUALIZATION_INPUT: &str = "Visualization Input";
93
94/// Diagram configuration and formatting
95pub const DIAGRAM_CONFIGURATION: &str = "Diagram Configuration";
96
97/// Graph traversal control
98pub const TRAVERSAL_CONTROL: &str = "Traversal Control";
99
100/// Cache input paths
101pub const CACHE_INPUT: &str = "Cache Input";
102
103/// Config command input specification
104pub const CONFIG_INPUT: &str = "Config Input";
105
106/// Safety controls for destructive operations
107pub const SAFETY_CONTROL: &str = "Safety Control";
108
109/// Workspace input paths
110pub const WORKSPACE_INPUT: &str = "Workspace Input";
111
112/// Workspace configuration options
113pub const WORKSPACE_CONFIGURATION: &str = "Workspace Configuration";
114
115// ===== Phase 4 Headings (Graph Command) =====
116
117/// Graph command root-level configuration
118pub const GRAPH_CONFIGURATION: &str = "Graph Configuration";
119
120// ===== Query Persistence Headings (P2-11/P2-17) =====
121
122/// Alias command input specification
123pub const ALIAS_INPUT: &str = "Alias Input";
124
125/// Alias command configuration options
126pub const ALIAS_CONFIGURATION: &str = "Alias Configuration";
127
128/// History command input specification
129pub const HISTORY_INPUT: &str = "History Input";
130
131/// History command configuration options
132pub const HISTORY_CONFIGURATION: &str = "History Configuration";
133
134/// Query persistence options (for --save-as on query/search)
135pub const PERSISTENCE_OPTIONS: &str = "Persistence Options";
136
137// ===== Natural Language Headings =====
138
139/// Natural language query input
140pub const NL_INPUT: &str = "Query Input";
141
142/// Natural language translation configuration
143pub const NL_CONFIGURATION: &str = "Translation Configuration";
144
145/// Graph analysis input targets
146pub const GRAPH_ANALYSIS_INPUT: &str = "Analysis Input";
147
148/// Graph filtering and constraints
149pub const GRAPH_FILTERING: &str = "Filtering & Constraints";
150
151/// Graph analysis options
152pub const GRAPH_ANALYSIS_OPTIONS: &str = "Analysis Options";
153
154/// Graph output customization
155pub const GRAPH_OUTPUT_OPTIONS: &str = "Output Options";
156
157/// Security limits for query execution (CD Static Analysis)
158pub const SECURITY_LIMITS: &str = "Security Limits";
159
160// ===== Local Uses and Insights Headings =====
161
162/// Insights command configuration
163pub const INSIGHTS_CONFIGURATION: &str = "Insights Configuration";
164
165/// Insights output options
166pub const INSIGHTS_OUTPUT: &str = "Output Options";
167
168// ===== Code Analysis Headings (Duplicates, Cycles, Unused) =====
169
170/// Duplicate detection options
171pub const DUPLICATE_OPTIONS: &str = "Duplicate Detection";
172
173/// Cycle detection options
174pub const CYCLE_OPTIONS: &str = "Cycle Detection";
175
176/// Unused code detection options
177pub const UNUSED_OPTIONS: &str = "Unused Code Detection";
178
179/// Export format options
180pub const EXPORT_OPTIONS: &str = "Export Options";
181
182// ===== Helper Functions =====
183
184/// Apply root-level command layout by setting subcommand headings
185///
186/// This function mutates the root `Command` to assign the `UTILITIES` heading
187/// to utility subcommands (batch, completions) while preserving existing
188/// search workflow headings.
189///
190/// # Arguments
191/// * `cmd` - The root command (typically from `Cli::command()`)
192///
193/// # Returns
194/// The mutated command with updated subcommand headings
195#[must_use]
196pub fn apply_root_layout(cmd: Command) -> Command {
197 cmd.mut_subcommand("batch", |sub| sub.next_help_heading(UTILITIES))
198 .mut_subcommand("completions", |sub| sub.next_help_heading(UTILITIES))
199}
200
201/// Normalize command for deterministic help output in tests
202///
203/// Applies consistent ordering and formatting to make help snapshots
204/// reproducible across environments.
205///
206/// # Arguments
207/// * `cmd` - The command to normalize
208///
209/// # Returns
210/// The normalized command
211#[must_use]
212pub fn normalize(cmd: Command) -> Command {
213 // Currently a pass-through; future phases may enforce display_order
214 cmd
215}