connection_string_parser/
cli.rs

1use clap::{Parser, ValueEnum};
2
3#[derive(ValueEnum, Clone, Debug)]
4pub enum Part {
5    Scheme,
6    Host,
7    Port,
8    User,
9    Password,
10    /// Often corresponds to the database name
11    Path,
12}
13
14#[derive(Parser, Debug)]
15#[command(
16    about,
17    author,
18    version,
19    propagate_version = true,
20    next_line_help = false,
21    disable_help_subcommand = true,
22    after_long_help = "This tool can be used to extract parts of a connection string. It is useful for extracting the database name from a connection string, for example."
23)]
24pub struct Cli {
25    /// The connection string to parse
26    pub url: String,
27
28    /// The part of the connection string to extract
29    #[arg(short, long, required = true)]
30    pub part: Part,
31
32    /// Fail silently even if the part is not found
33    #[arg(short, long, default_value = "false")]
34    pub fail_silently: bool,
35}