Skip to main content

radicle_cli/commands/config/
args.rs

1use clap::{Parser, Subcommand};
2use radicle::node::Alias;
3
4const ABOUT: &str = "Manage your local Radicle configuration";
5
6const LONG_ABOUT: &str = r#"
7If no argument is specified, prints the current radicle configuration as JSON.
8To initialize a new configuration file, use `rad config init`.
9"#;
10
11#[derive(Debug, Parser)]
12#[command(about = ABOUT, long_about = LONG_ABOUT, disable_version_flag = true)]
13pub struct Args {
14    #[command(subcommand)]
15    pub(crate) command: Option<Command>,
16}
17
18#[derive(Subcommand, Debug)]
19#[group(multiple = false)]
20pub(crate) enum Command {
21    /// Show the current radicle configuration as JSON (default)
22    Show,
23    /// Initialize a new config file
24    Init {
25        /// Alias to use for the new configuration
26        #[arg(long)]
27        alias: Alias,
28    },
29    /// Open the config in your editor
30    Edit,
31    /// Get a value from the current configuration
32    Get {
33        /// The JSON key path to the value you want to get
34        key: String,
35    },
36    /// Prints the JSON Schema of the Radicle configuration
37    Schema,
38    /// Set a key to a value in the current configuration
39    Set {
40        /// The JSON key path to the value you want to set
41        key: String,
42        /// The JSON value used to set the field
43        value: String,
44    },
45    /// Set a key in the current configuration to `null`
46    Unset {
47        /// The JSON key path to the value you want to unset
48        key: String,
49    },
50    /// Push a value onto an array, which is identified by the key, in the
51    /// current configuration
52    Push {
53        /// The JSON key path to the array you want to push to
54        key: String,
55        /// The JSON value being pushed onto the array
56        value: String,
57    },
58    /// Remove a value from an array, which is identified by the key, in the
59    /// current configuration
60    ///
61    /// All instances of the value in the array will be removed
62    Remove {
63        /// The JSON key path to the array you want to push to
64        key: String,
65        /// The JSON value being pushed onto the array
66        value: String,
67    },
68}