tag2upload_service_manager/
cli_decl.rs

1//! CLI definition
2//!
3//! Command-line handling code present even in tests (ie, when mocking)
4
5use crate::prelude::*;
6
7#[derive(Debug)]
8pub struct WholeConfig {
9    pub cli_options: CliOptions,
10    pub config: Config,
11    pub computed_config: ComputedConfig,
12    pub rocket_config: figment::Figment,
13}
14
15#[derive(Debug, clap::Parser)]
16#[command(after_help = format!(
17r#"tag2upload-service-manager ({})
18Copyright Ian Jackson, Sean Whitton and contributors to tag2upload.
19This is Free Software with NO WARRANTY.  GPL-3.0-or-later.
20"#, crate::version::raw_info()))]
21pub struct CliOptions {
22    #[arg(short, long)]
23    pub config: Vec<String>,
24
25    #[arg(short = 'C', long)]
26    pub config_toml: Vec<String>,
27
28    #[command(subcommand)]
29    pub op: CliOperation,
30}
31
32#[derive(Debug, Clone, clap::Subcommand)]
33pub enum CliOperation {
34    RunManager {},
35    CheckConfig {},
36    CheckConfigSyntax {},
37    PreInstallCheck {},
38    PrintDatabaseSchema {},
39    PrintDatabaseSchemaVersion {},
40    /// Reads a `BSQL_COVERAGE_RECORD` format file on stdin and
41    /// checks it mentions every `bsql!` in the source code.
42    BsqlCheckCoverage {},
43    BsqlPrintQueryPlans {},
44    BsqlPrintSourceLocs {},
45
46    /// Attempt a schema migration, ad-hoc, on a specified file
47    ///
48    ///  * No db retries are done, so this shouldn't be done in a prod
49    ///  * By default, it doesn't commit the migration
50    SchemaMigrationAdhoc {
51        #[arg(long)]
52        commit: bool,
53        db_file: String,
54        from_version: db_support::SchemaVersion,
55        to_version: db_support::SchemaVersion,
56        /// Files in here that look like db files will be deleted!
57        temp_dir: String,
58    },
59}