diff options
Diffstat (limited to 'src/bin/ngit')
| -rw-r--r-- | src/bin/ngit/cli.rs | 16 | ||||
| -rw-r--r-- | src/bin/ngit/main.rs | 12 |
2 files changed, 21 insertions, 7 deletions
diff --git a/src/bin/ngit/cli.rs b/src/bin/ngit/cli.rs index fce5664..851dd70 100644 --- a/src/bin/ngit/cli.rs +++ b/src/bin/ngit/cli.rs | |||
| @@ -57,8 +57,6 @@ pub enum Commands { | |||
| 57 | Fetch(sub_commands::fetch::SubCommandArgs), | 57 | Fetch(sub_commands::fetch::SubCommandArgs), |
| 58 | /// signal you are this repo's maintainer accepting proposals via nostr | 58 | /// signal you are this repo's maintainer accepting proposals via nostr |
| 59 | Init(sub_commands::init::SubCommandArgs), | 59 | Init(sub_commands::init::SubCommandArgs), |
| 60 | /// export nostr keys to login to other nostr clients | ||
| 61 | ExportKeys, | ||
| 62 | /// issue commits as a proposal | 60 | /// issue commits as a proposal |
| 63 | Send(sub_commands::send::SubCommandArgs), | 61 | Send(sub_commands::send::SubCommandArgs), |
| 64 | /// list proposals; checkout, apply or download selected | 62 | /// list proposals; checkout, apply or download selected |
| @@ -67,8 +65,22 @@ pub enum Commands { | |||
| 67 | Push(sub_commands::push::SubCommandArgs), | 65 | Push(sub_commands::push::SubCommandArgs), |
| 68 | /// fetch and apply new proposal commits / revisions linked to branch | 66 | /// fetch and apply new proposal commits / revisions linked to branch |
| 69 | Pull, | 67 | Pull, |
| 68 | /// login, logout or export keys | ||
| 69 | Account(AccountSubCommandArgs), | ||
| 70 | } | ||
| 71 | |||
| 72 | #[derive(Subcommand)] | ||
| 73 | pub enum AccountCommands { | ||
| 70 | /// run with --nsec flag to change npub | 74 | /// run with --nsec flag to change npub |
| 71 | Login(sub_commands::login::SubCommandArgs), | 75 | Login(sub_commands::login::SubCommandArgs), |
| 72 | /// remove nostr account details stored in git config | 76 | /// remove nostr account details stored in git config |
| 73 | Logout, | 77 | Logout, |
| 78 | /// export nostr keys to login to other nostr clients | ||
| 79 | ExportKeys, | ||
| 80 | } | ||
| 81 | |||
| 82 | #[derive(clap::Parser)] | ||
| 83 | pub struct AccountSubCommandArgs { | ||
| 84 | #[command(subcommand)] | ||
| 85 | pub account_command: AccountCommands, | ||
| 74 | } | 86 | } |
diff --git a/src/bin/ngit/main.rs b/src/bin/ngit/main.rs index cdd0e97..a49267b 100644 --- a/src/bin/ngit/main.rs +++ b/src/bin/ngit/main.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use anyhow::Result; | 5 | use anyhow::Result; |
| 6 | use clap::Parser; | 6 | use clap::Parser; |
| 7 | use cli::{Cli, Commands}; | 7 | use cli::{AccountCommands, Cli, Commands}; |
| 8 | 8 | ||
| 9 | mod cli; | 9 | mod cli; |
| 10 | use ngit::{cli_interactor, client, git, git_events, login, repo_ref}; | 10 | use ngit::{cli_interactor, client, git, git_events, login, repo_ref}; |
| @@ -15,14 +15,16 @@ mod sub_commands; | |||
| 15 | async fn main() -> Result<()> { | 15 | async fn main() -> Result<()> { |
| 16 | let cli = Cli::parse(); | 16 | let cli = Cli::parse(); |
| 17 | match &cli.command { | 17 | match &cli.command { |
| 18 | Commands::Account(args) => match &args.account_command { | ||
| 19 | AccountCommands::Login(sub_args) => sub_commands::login::launch(&cli, sub_args).await, | ||
| 20 | AccountCommands::Logout => sub_commands::logout::launch().await, | ||
| 21 | AccountCommands::ExportKeys => sub_commands::export_keys::launch().await, | ||
| 22 | }, | ||
| 18 | Commands::Fetch(args) => sub_commands::fetch::launch(&cli, args).await, | 23 | Commands::Fetch(args) => sub_commands::fetch::launch(&cli, args).await, |
| 19 | Commands::Login(args) => sub_commands::login::launch(&cli, args).await, | ||
| 20 | Commands::Logout => sub_commands::logout::launch().await, | ||
| 21 | Commands::Init(args) => sub_commands::init::launch(&cli, args).await, | 24 | Commands::Init(args) => sub_commands::init::launch(&cli, args).await, |
| 22 | Commands::ExportKeys => sub_commands::export_keys::launch().await, | ||
| 23 | Commands::Send(args) => sub_commands::send::launch(&cli, args, false).await, | ||
| 24 | Commands::List => sub_commands::list::launch().await, | 25 | Commands::List => sub_commands::list::launch().await, |
| 25 | Commands::Pull => sub_commands::pull::launch().await, | 26 | Commands::Pull => sub_commands::pull::launch().await, |
| 26 | Commands::Push(args) => sub_commands::push::launch(&cli, args).await, | 27 | Commands::Push(args) => sub_commands::push::launch(&cli, args).await, |
| 28 | Commands::Send(args) => sub_commands::send::launch(&cli, args, false).await, | ||
| 27 | } | 29 | } |
| 28 | } | 30 | } |