diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-10 12:51:45 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-10 13:03:31 +0000 |
| commit | 9d142ee7046a415bb764f626e61476ed349c98ca (patch) | |
| tree | 11b91693428055590ed44c7c180f2a985a8ac944 /src/bin/ngit/cli.rs | |
| parent | d2412565334f48bd31e57d29d7959c24258ccd98 (diff) | |
feat: add global CLI flags for non-interactive mode
Add --defaults, --interactive, and --force flags to support non-interactive
operation. Non-interactive mode is now the default behavior, with interactive
mode enabled via the -i/--interactive flag.
Also add CliError handling in main() to support styled error output from
subcommands.
Diffstat (limited to 'src/bin/ngit/cli.rs')
| -rw-r--r-- | src/bin/ngit/cli.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/bin/ngit/cli.rs b/src/bin/ngit/cli.rs index 76874c3..d2246d7 100644 --- a/src/bin/ngit/cli.rs +++ b/src/bin/ngit/cli.rs | |||
| @@ -11,6 +11,7 @@ use crate::sub_commands; | |||
| 11 | help_template = "{name} {version}\nnostr plugin for git\n - clone a nostr repository, or add as a remote, by using the url format nostr://pub123/identifier\n - remote branches beginning with `pr/` are open PRs from contributors; `ngit list` can be used to view all PRs\n - to open a PR, push a branch with the prefix `pr/` or use `ngit send` for advanced options\n- publish a repository to nostr with `ngit init`\n\n{usage}\n{all-args}" | 11 | help_template = "{name} {version}\nnostr plugin for git\n - clone a nostr repository, or add as a remote, by using the url format nostr://pub123/identifier\n - remote branches beginning with `pr/` are open PRs from contributors; `ngit list` can be used to view all PRs\n - to open a PR, push a branch with the prefix `pr/` or use `ngit send` for advanced options\n- publish a repository to nostr with `ngit init`\n\n{usage}\n{all-args}" |
| 12 | )] | 12 | )] |
| 13 | #[command(propagate_version = true)] | 13 | #[command(propagate_version = true)] |
| 14 | #[allow(clippy::struct_excessive_bools)] | ||
| 14 | pub struct Cli { | 15 | pub struct Cli { |
| 15 | #[command(subcommand)] | 16 | #[command(subcommand)] |
| 16 | pub command: Option<Commands>, | 17 | pub command: Option<Commands>, |
| @@ -32,6 +33,15 @@ pub struct Cli { | |||
| 32 | /// show customization options via git config | 33 | /// show customization options via git config |
| 33 | #[arg(short, long, global = true)] | 34 | #[arg(short, long, global = true)] |
| 34 | pub customize: bool, | 35 | pub customize: bool, |
| 36 | /// Use default values without prompting (non-interactive mode) | ||
| 37 | #[arg(short = 'd', long, global = true, conflicts_with = "interactive")] | ||
| 38 | pub defaults: bool, | ||
| 39 | /// Enable interactive prompts (default behavior) | ||
| 40 | #[arg(short = 'i', long, global = true)] | ||
| 41 | pub interactive: bool, | ||
| 42 | /// Force operations, bypass safety guards | ||
| 43 | #[arg(short = 'f', long, global = true)] | ||
| 44 | pub force: bool, | ||
| 35 | } | 45 | } |
| 36 | 46 | ||
| 37 | pub const CUSTOMISE_TEMPLATE: &str = r" | 47 | pub const CUSTOMISE_TEMPLATE: &str = r" |
| @@ -111,6 +121,8 @@ pub enum AccountCommands { | |||
| 111 | Logout, | 121 | Logout, |
| 112 | /// export nostr keys to login to other nostr clients | 122 | /// export nostr keys to login to other nostr clients |
| 113 | ExportKeys, | 123 | ExportKeys, |
| 124 | /// create a new nostr account | ||
| 125 | Create(sub_commands::create::SubCommandArgs), | ||
| 114 | } | 126 | } |
| 115 | 127 | ||
| 116 | #[derive(clap::Parser)] | 128 | #[derive(clap::Parser)] |