oxilean-cli 0.1.2

OxiLean command-line interface
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
//! Auto-generated module
//!
//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)

use super::functions::*;
use crate::repl::Repl;

/// Diagnostic severity.
#[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DiagSeverity {
    Error,
    Warning,
    Note,
    Hint,
}
/// Reporter for command-line diagnostic output.
#[allow(dead_code)]
pub struct CliDiagnosticsReporter {
    pub use_color: bool,
    pub compact: bool,
}
impl CliDiagnosticsReporter {
    /// Create a new reporter.
    #[allow(dead_code)]
    pub fn new(use_color: bool) -> Self {
        Self {
            use_color,
            compact: false,
        }
    }
    /// Format a count summary.
    #[allow(dead_code)]
    pub fn format_summary(&self, errors: usize, warnings: usize) -> String {
        if errors == 0 && warnings == 0 {
            "No errors or warnings.".to_string()
        } else {
            format!("{} error(s), {} warning(s)", errors, warnings)
        }
    }
}
/// Supported CLI commands (parsed from argv).
#[allow(dead_code)]
pub enum CliCommand {
    /// Start the interactive REPL.
    Repl,
    /// Check a single `.oxilean` file.
    Check(String),
    /// Show version information.
    Version,
    /// Show help message.
    Help,
    /// Build a project from a manifest file.
    Build { manifest: String },
    /// Run benchmarks.
    Bench { file: String },
    /// Generate documentation.
    Doc { output: String },
    /// Format a source file in-place.
    Fmt { file: String },
    /// Start the LSP language server.
    Lsp,
    /// Export declarations to JSON.
    Export { file: String, output: String },
    /// Unknown command with its name.
    Unknown(String),
}
#[allow(dead_code)]
impl CliCommand {
    /// Parse a `CliCommand` from a slice of argument strings.
    pub fn parse(args: &[String]) -> Self {
        let cmd = args.first().map(|s| s.as_str()).unwrap_or("");
        match cmd {
            "repl" | "r" => CliCommand::Repl,
            "check" | "c" => {
                let file = args.get(1).cloned().unwrap_or_default();
                CliCommand::Check(file)
            }
            "version" | "v" | "--version" | "-V" => CliCommand::Version,
            "help" | "h" | "--help" | "-h" => CliCommand::Help,
            "build" | "b" => {
                let manifest = args
                    .get(1)
                    .cloned()
                    .unwrap_or_else(|| "Oxilean.toml".to_string());
                CliCommand::Build { manifest }
            }
            "bench" => {
                let file = args.get(1).cloned().unwrap_or_default();
                CliCommand::Bench { file }
            }
            "doc" => {
                let output = args.get(1).cloned().unwrap_or_else(|| "docs".to_string());
                CliCommand::Doc { output }
            }
            "fmt" | "format" => {
                let file = args.get(1).cloned().unwrap_or_default();
                CliCommand::Fmt { file }
            }
            "lsp" => CliCommand::Lsp,
            "export" => {
                let file = args.get(1).cloned().unwrap_or_default();
                let output = args
                    .get(2)
                    .cloned()
                    .unwrap_or_else(|| "output.json".to_string());
                CliCommand::Export { file, output }
            }
            other => CliCommand::Unknown(other.to_string()),
        }
    }
    /// Return a one-line description of this command.
    pub fn description(&self) -> &'static str {
        match self {
            CliCommand::Repl => "Start the interactive REPL",
            CliCommand::Check(_) => "Type-check a .oxilean source file",
            CliCommand::Version => "Print version information",
            CliCommand::Help => "Print this help message",
            CliCommand::Build { .. } => "Build a project from its manifest",
            CliCommand::Bench { .. } => "Run benchmarks on a file",
            CliCommand::Doc { .. } => "Generate HTML documentation",
            CliCommand::Fmt { .. } => "Format a source file in-place",
            CliCommand::Lsp => "Start the LSP language server",
            CliCommand::Export { .. } => "Export declarations to JSON",
            CliCommand::Unknown(_) => "Unknown command",
        }
    }
    /// Return true if this command requires at least one file argument.
    pub fn requires_file(&self) -> bool {
        matches!(
            self,
            CliCommand::Check(_)
                | CliCommand::Bench { .. }
                | CliCommand::Fmt { .. }
                | CliCommand::Export { .. }
        )
    }
}
/// Parsed global CLI arguments.
#[allow(dead_code)]
#[derive(Clone, Debug, Default)]
pub struct GlobalArgs {
    pub verbose: bool,
    pub quiet: bool,
    pub color: ColorChoice,
    pub log_level: String,
    pub config_path: Option<String>,
    pub no_config: bool,
}
/// Shell variants for completion generation.
#[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Shell {
    Bash,
    Zsh,
    Fish,
    PowerShell,
    Elvish,
}
#[allow(dead_code)]
impl Shell {
    pub fn from_str(s: &str) -> Option<Self> {
        match s.to_ascii_lowercase().as_str() {
            "bash" => Some(Shell::Bash),
            "zsh" => Some(Shell::Zsh),
            "fish" => Some(Shell::Fish),
            "powershell" | "ps" => Some(Shell::PowerShell),
            "elvish" => Some(Shell::Elvish),
            _ => None,
        }
    }
}
/// A CLI diagnostic message.
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct CliDiagnostic {
    pub severity: DiagSeverity,
    pub message: String,
    pub file: Option<String>,
    pub line: Option<usize>,
    pub column: Option<usize>,
    pub snippet: Option<String>,
    pub suggestion: Option<String>,
}
#[allow(dead_code)]
impl CliDiagnostic {
    pub fn error(message: impl Into<String>) -> Self {
        Self {
            severity: DiagSeverity::Error,
            message: message.into(),
            file: None,
            line: None,
            column: None,
            snippet: None,
            suggestion: None,
        }
    }
    pub fn warning(message: impl Into<String>) -> Self {
        Self {
            severity: DiagSeverity::Warning,
            message: message.into(),
            file: None,
            line: None,
            column: None,
            snippet: None,
            suggestion: None,
        }
    }
    pub fn at_file(mut self, file: impl Into<String>) -> Self {
        self.file = Some(file.into());
        self
    }
    pub fn at_location(mut self, line: usize, column: usize) -> Self {
        self.line = Some(line);
        self.column = Some(column);
        self
    }
    pub fn with_snippet(mut self, snippet: impl Into<String>) -> Self {
        self.snippet = Some(snippet.into());
        self
    }
    pub fn with_suggestion(mut self, s: impl Into<String>) -> Self {
        self.suggestion = Some(s.into());
        self
    }
    pub fn format(&self, _color: bool) -> String {
        let location = match (&self.file, self.line, self.column) {
            (Some(f), Some(l), Some(c)) => format!("{}:{}:{}: ", f, l, c),
            (Some(f), Some(l), None) => format!("{}:{}: ", f, l),
            (Some(f), None, _) => format!("{}: ", f),
            _ => String::new(),
        };
        let mut lines = vec![format!("{}{}: {}", location, self.severity, self.message)];
        if let Some(ref s) = self.snippet {
            lines.push(format!("  | {}", s));
        }
        if let Some(ref s) = self.suggestion {
            lines.push(format!("  suggestion: {}", s));
        }
        lines.join("\n")
    }
}
/// The result of a CLI execution.
#[allow(dead_code)]
#[derive(Clone, Debug)]
pub struct CliExecutionResult {
    pub exit_code: i32,
    pub output: String,
    pub duration_ms: u64,
}
impl CliExecutionResult {
    /// Create a successful result.
    #[allow(dead_code)]
    pub fn ok(output: impl Into<String>, duration_ms: u64) -> Self {
        Self {
            exit_code: 0,
            output: output.into(),
            duration_ms,
        }
    }
    /// Create a failure result.
    #[allow(dead_code)]
    pub fn err(exit_code: i32, output: impl Into<String>, duration_ms: u64) -> Self {
        Self {
            exit_code,
            output: output.into(),
            duration_ms,
        }
    }
    /// Return whether the execution was successful.
    #[allow(dead_code)]
    pub fn is_success(&self) -> bool {
        self.exit_code == 0
    }
}
/// Color output choice.
#[allow(dead_code)]
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub enum ColorChoice {
    #[default]
    Auto,
    Always,
    Never,
}
impl ColorChoice {
    /// Parse from a string.
    #[allow(dead_code)]
    pub fn from_str(s: &str) -> Option<Self> {
        match s.to_lowercase().as_str() {
            "auto" => Some(Self::Auto),
            "always" | "yes" => Some(Self::Always),
            "never" | "no" => Some(Self::Never),
            _ => None,
        }
    }
    /// Return true if color output should be enabled.
    #[allow(dead_code)]
    pub fn is_enabled(&self) -> bool {
        match self {
            Self::Auto => atty_check(),
            Self::Always => true,
            Self::Never => false,
        }
    }
}
/// CLI build information.
#[allow(dead_code)]
pub struct CliBuildInfo {
    pub version: &'static str,
    pub git_commit: Option<&'static str>,
    pub build_date: &'static str,
    pub target_triple: &'static str,
    pub rustc_version: &'static str,
    pub profile: &'static str,
}
impl CliBuildInfo {
    /// Return the default build info.
    #[allow(dead_code)]
    pub fn current() -> Self {
        Self {
            version: env!("CARGO_PKG_VERSION"),
            git_commit: option_env!("GIT_COMMIT"),
            build_date: "2025-02-28",
            target_triple: std::env::consts::ARCH,
            rustc_version: "stable",
            profile: if cfg!(debug_assertions) {
                "debug"
            } else {
                "release"
            },
        }
    }
    /// Format as a version string.
    #[allow(dead_code)]
    pub fn version_string(&self) -> String {
        match self.git_commit {
            Some(commit) => {
                format!("oxilean {} ({}) [{}]", self.version, commit, self.profile)
            }
            None => format!("oxilean {} [{}]", self.version, self.profile),
        }
    }
}
/// Detailed version information.
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct VersionInfo {
    pub version: String,
    pub git_hash: Option<String>,
    pub build_date: String,
    pub rustc_version: String,
    pub target: String,
}
#[allow(dead_code)]
impl VersionInfo {
    pub fn current() -> Self {
        Self {
            version: env!("CARGO_PKG_VERSION").to_string(),
            git_hash: option_env!("GIT_HASH").map(|s| s.to_string()),
            build_date: option_env!("BUILD_DATE").unwrap_or("unknown").to_string(),
            rustc_version: option_env!("RUSTC_VERSION")
                .unwrap_or("unknown")
                .to_string(),
            target: option_env!("TARGET")
                .unwrap_or(std::env::consts::ARCH)
                .to_string(),
        }
    }
    pub fn short_version(&self) -> String {
        format!("oxilean {}", self.version)
    }
    pub fn long_version(&self) -> String {
        let mut lines = vec![format!("oxilean {}", self.version)];
        if let Some(ref h) = self.git_hash {
            lines.push(format!("commit: {}", h));
        }
        lines.push(format!("build date: {}", self.build_date));
        lines.push(format!("target: {}", self.target));
        lines.join("\n")
    }
}
/// Global flags.
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct GlobalFlags {
    pub verbose: bool,
    pub quiet: bool,
    pub no_color: bool,
    pub jobs: usize,
    pub log_level: String,
    pub work_dir: Option<String>,
    pub telemetry: bool,
    pub check_updates: bool,
}
#[allow(dead_code)]
impl GlobalFlags {
    pub fn default_flags() -> Self {
        Self {
            verbose: false,
            quiet: false,
            no_color: false,
            jobs: num_cpus(),
            log_level: "warn".to_string(),
            work_dir: None,
            telemetry: false,
            check_updates: true,
        }
    }
    pub fn parse(args: &mut Vec<String>) -> Self {
        let mut flags = Self::default_flags();
        let mut i = 0;
        while i < args.len() {
            match args[i].as_str() {
                "--verbose" | "-v" => {
                    flags.verbose = true;
                    args.remove(i);
                }
                "--quiet" | "-q" => {
                    flags.quiet = true;
                    args.remove(i);
                }
                "--no-color" => {
                    flags.no_color = true;
                    args.remove(i);
                }
                "--telemetry" => {
                    flags.telemetry = true;
                    args.remove(i);
                }
                "--no-telemetry" => {
                    flags.telemetry = false;
                    args.remove(i);
                }
                "--no-update-check" => {
                    flags.check_updates = false;
                    args.remove(i);
                }
                arg if arg.starts_with("--jobs=") => {
                    if let Ok(n) = arg["--jobs=".len()..].parse::<usize>() {
                        flags.jobs = n;
                    }
                    args.remove(i);
                }
                arg if arg.starts_with("--log=") => {
                    flags.log_level = arg["--log=".len()..].to_string();
                    args.remove(i);
                }
                _ => {
                    i += 1;
                }
            }
        }
        flags
    }
    pub fn apply(&self) {
        if self.no_color {
            std::env::set_var("NO_COLOR", "1");
        }
        if self.verbose {
            std::env::set_var("OXILEAN_LOG", "debug");
        } else {
            std::env::set_var("OXILEAN_LOG", &self.log_level);
        }
    }
}
/// CLI environment configuration.
#[allow(dead_code)]
#[derive(Clone, Debug)]
pub struct CliEnvironment {
    pub oxilean_home: Option<String>,
    pub oxilean_stdlib: Option<String>,
    pub oxilean_cache: Option<String>,
    pub editor: Option<String>,
    pub pager: Option<String>,
    pub no_color: bool,
    pub ci_mode: bool,
}
impl CliEnvironment {
    /// Detect environment from system variables.
    #[allow(dead_code)]
    pub fn detect() -> Self {
        Self {
            oxilean_home: std::env::var("OXILEAN_HOME").ok(),
            oxilean_stdlib: std::env::var("OXILEAN_STDLIB").ok(),
            oxilean_cache: std::env::var("OXILEAN_CACHE").ok(),
            editor: std::env::var("EDITOR").ok(),
            pager: std::env::var("PAGER").ok(),
            no_color: std::env::var("NO_COLOR").is_ok(),
            ci_mode: std::env::var("CI").is_ok(),
        }
    }
    /// Return whether interactive mode is appropriate.
    #[allow(dead_code)]
    pub fn is_interactive(&self) -> bool {
        !self.ci_mode
    }
}
/// A simple progress indicator for multi-step operations.
#[allow(dead_code)]
pub struct ProgressBar {
    total: usize,
    pub(crate) current: usize,
    label: String,
}
#[allow(dead_code)]
impl ProgressBar {
    /// Create a new progress bar with the given total.
    pub fn new(total: usize, label: impl Into<String>) -> Self {
        Self {
            total,
            current: 0,
            label: label.into(),
        }
    }
    /// Advance by one step.
    pub fn tick(&mut self) {
        self.current = (self.current + 1).min(self.total);
    }
    /// Advance by `n` steps.
    pub fn advance(&mut self, n: usize) {
        self.current = (self.current + n).min(self.total);
    }
    /// Return the current completion percentage (0–100).
    pub fn percent(&self) -> u32 {
        if self.total == 0 {
            return 100;
        }
        (self.current * 100 / self.total) as u32
    }
    /// Return true if complete.
    pub fn is_complete(&self) -> bool {
        self.current >= self.total
    }
    /// Format as a simple ASCII bar of given width.
    pub fn render(&self, bar_width: usize) -> String {
        let filled = (self.current * bar_width)
            .checked_div(self.total)
            .unwrap_or(bar_width);
        let empty = bar_width - filled;
        format!(
            "[{}{}] {}/{} {}",
            "#".repeat(filled),
            "-".repeat(empty),
            self.current,
            self.total,
            self.label
        )
    }
}
/// Global CLI configuration (flags and settings).
#[allow(dead_code)]
pub struct CliConfig {
    /// Whether verbose output is enabled (`--verbose` / `-v`).
    pub verbose: bool,
    /// Whether to suppress all output (`--quiet` / `-q`).
    pub quiet: bool,
    /// Maximum number of errors to report before stopping.
    pub max_errors: usize,
    /// Whether to use colored terminal output.
    pub color: bool,
    /// Output width for pretty-printing (0 = auto-detect).
    pub width: usize,
}
#[allow(dead_code)]
impl CliConfig {
    /// Create a default `CliConfig`.
    pub fn default_config() -> Self {
        CliConfig {
            verbose: false,
            quiet: false,
            max_errors: 100,
            color: true,
            width: 0,
        }
    }
    /// Parse flags from an argv slice (mutates the slice by removing recognized flags).
    pub fn parse_flags(args: &mut Vec<String>) -> Self {
        let mut cfg = Self::default_config();
        args.retain(|arg| match arg.as_str() {
            "--verbose" | "-v" => {
                cfg.verbose = true;
                false
            }
            "--quiet" | "-q" => {
                cfg.quiet = true;
                false
            }
            "--no-color" => {
                cfg.color = false;
                false
            }
            _ => true,
        });
        cfg
    }
    /// Print a verbose message if verbose mode is enabled.
    pub fn vlog(&self, msg: &str) {
        if self.verbose {
            eprintln!("[verbose] {msg}");
        }
    }
}
/// Extended subcommand set with more options.
#[allow(dead_code)]
pub enum ExtCommand {
    Init {
        name: String,
    },
    Test {
        filter: Option<String>,
    },
    Clean {
        profile: String,
    },
    Update,
    Deps,
    Search {
        pattern: String,
    },
    Proof {
        file: String,
    },
    Lint {
        paths: Vec<String>,
    },
    Report {
        output: String,
    },
    Watch {
        dirs: Vec<String>,
    },
    Benchmark {
        file: String,
        filter: Option<String>,
    },
    Diff {
        old: String,
        new: String,
    },
    Migrate {
        version: String,
    },
}
#[allow(dead_code)]
impl ExtCommand {
    pub fn parse(args: &[String]) -> Option<Self> {
        let cmd = args.first()?.as_str();
        match cmd {
            "init" => Some(ExtCommand::Init {
                name: args
                    .get(1)
                    .cloned()
                    .unwrap_or_else(|| "my-project".to_string()),
            }),
            "test" => Some(ExtCommand::Test {
                filter: args.get(1).cloned(),
            }),
            "clean" => Some(ExtCommand::Clean {
                profile: args.get(1).cloned().unwrap_or_else(|| "debug".to_string()),
            }),
            "update" => Some(ExtCommand::Update),
            "deps" => Some(ExtCommand::Deps),
            "search" => Some(ExtCommand::Search {
                pattern: args.get(1).cloned().unwrap_or_default(),
            }),
            "proof" => Some(ExtCommand::Proof {
                file: args.get(1).cloned().unwrap_or_default(),
            }),
            "lint" => Some(ExtCommand::Lint {
                paths: args[1..].to_vec(),
            }),
            "report" => Some(ExtCommand::Report {
                output: args
                    .get(1)
                    .cloned()
                    .unwrap_or_else(|| "report.html".to_string()),
            }),
            "watch" => Some(ExtCommand::Watch {
                dirs: if args.len() > 1 {
                    args[1..].to_vec()
                } else {
                    vec![".".to_string()]
                },
            }),
            "benchmark" => Some(ExtCommand::Benchmark {
                file: args.get(1).cloned().unwrap_or_default(),
                filter: args.get(2).cloned(),
            }),
            "diff" => Some(ExtCommand::Diff {
                old: args.get(1).cloned().unwrap_or_default(),
                new: args.get(2).cloned().unwrap_or_default(),
            }),
            "migrate" => Some(ExtCommand::Migrate {
                version: args.get(1).cloned().unwrap_or_default(),
            }),
            _ => None,
        }
    }
    pub fn description(&self) -> &'static str {
        match self {
            ExtCommand::Init { .. } => "Initialize a new project",
            ExtCommand::Test { .. } => "Run project tests",
            ExtCommand::Clean { .. } => "Clean build artifacts",
            ExtCommand::Update => "Upgrade dependencies",
            ExtCommand::Deps => "Show dependency tree",
            ExtCommand::Search { .. } => "Search declarations",
            ExtCommand::Proof { .. } => "Interactive proof session",
            ExtCommand::Lint { .. } => "Lint source files",
            ExtCommand::Report { .. } => "Generate project report",
            ExtCommand::Watch { .. } => "Watch and auto-rebuild",
            ExtCommand::Benchmark { .. } => "Run benchmarks",
            ExtCommand::Diff { .. } => "Diff two versions",
            ExtCommand::Migrate { .. } => "Migrate to new syntax",
        }
    }
    pub fn is_mutating(&self) -> bool {
        matches!(
            self,
            ExtCommand::Init { .. }
                | ExtCommand::Clean { .. }
                | ExtCommand::Update
                | ExtCommand::Migrate { .. }
        )
    }
}
/// Telemetry configuration.
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct TelemetryConfig {
    pub enabled: bool,
    pub session_id: String,
    pub endpoint: String,
}
#[allow(dead_code)]
impl TelemetryConfig {
    pub fn default_config() -> Self {
        Self {
            enabled: false,
            session_id: generate_session_id(),
            endpoint: String::new(),
        }
    }
    pub fn opt_in(mut self) -> Self {
        self.enabled = true;
        self
    }
    pub fn opt_out(mut self) -> Self {
        self.enabled = false;
        self
    }
    pub fn effective_endpoint(&self) -> &str {
        if self.enabled {
            &self.endpoint
        } else {
            ""
        }
    }
}
/// A subcommand name with aliases.
#[allow(dead_code)]
#[derive(Clone, Debug)]
pub struct SubcommandEntry {
    pub name: &'static str,
    pub aliases: &'static [&'static str],
    pub description: &'static str,
}
/// The result of a CLI operation.
#[allow(dead_code)]
pub enum CliResult {
    /// Success (exit code 0).
    Ok,
    /// Failure with a message (exit code 1).
    Err(String),
    /// Failure with a specific exit code.
    Exit(i32),
}
#[allow(dead_code)]
impl CliResult {
    /// Convert to a process exit code.
    pub fn exit_code(&self) -> i32 {
        match self {
            CliResult::Ok => 0,
            CliResult::Err(_) => 1,
            CliResult::Exit(code) => *code,
        }
    }
    /// Return true if the result is a success.
    pub fn is_ok(&self) -> bool {
        matches!(self, CliResult::Ok)
    }
}