diff options
Diffstat (limited to 'src/bin/ngit/main.rs')
| -rw-r--r-- | src/bin/ngit/main.rs | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/bin/ngit/main.rs b/src/bin/ngit/main.rs index a6e3e11..f896e97 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::{AccountCommands, Cli, Commands}; | 7 | use cli::{AccountCommands, CUSTOMISE_TEMPLATE, 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}; |
| @@ -14,14 +14,28 @@ mod sub_commands; | |||
| 14 | #[tokio::main] | 14 | #[tokio::main] |
| 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 | |
| 18 | Commands::Account(args) => match &args.account_command { | 18 | if cli.customize { |
| 19 | AccountCommands::Login(sub_args) => sub_commands::login::launch(&cli, sub_args).await, | 19 | print!("{CUSTOMISE_TEMPLATE}"); |
| 20 | AccountCommands::Logout => sub_commands::logout::launch().await, | 20 | std::process::exit(0); // Exit the program |
| 21 | AccountCommands::ExportKeys => sub_commands::export_keys::launch().await, | 21 | } |
| 22 | }, | 22 | |
| 23 | Commands::Init(args) => sub_commands::init::launch(&cli, args).await, | 23 | if let Some(command) = &cli.command { |
| 24 | Commands::List => sub_commands::list::launch().await, | 24 | match command { |
| 25 | Commands::Send(args) => sub_commands::send::launch(&cli, args, false).await, | 25 | Commands::Account(args) => match &args.account_command { |
| 26 | AccountCommands::Login(sub_args) => { | ||
| 27 | sub_commands::login::launch(&cli, sub_args).await | ||
| 28 | } | ||
| 29 | AccountCommands::Logout => sub_commands::logout::launch().await, | ||
| 30 | AccountCommands::ExportKeys => sub_commands::export_keys::launch().await, | ||
| 31 | }, | ||
| 32 | Commands::Init(args) => sub_commands::init::launch(&cli, args).await, | ||
| 33 | Commands::List => sub_commands::list::launch().await, | ||
| 34 | Commands::Send(args) => sub_commands::send::launch(&cli, args, false).await, | ||
| 35 | } | ||
| 36 | } else { | ||
| 37 | // Handle the case where no command is provided | ||
| 38 | eprintln!("Error: A command must be provided. Use '--help' for more information."); | ||
| 39 | std::process::exit(1); | ||
| 26 | } | 40 | } |
| 27 | } | 41 | } |