upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/main.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-05-21 13:16:25 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-05-21 16:21:31 +0100
commitd0a27fc7828aee5ca7d4c56a9c9f9f5b08878fbf (patch)
tree07fcb43d5afe6ef2dbf5ab9168d9e6fb2bd1b1a4 /src/bin/ngit/main.rs
parentd64748b810bf64638a5eb71eac054d91dae0c0f1 (diff)
feat: add --customize flag for instructions
of how to customise ngit via git config items
Diffstat (limited to 'src/bin/ngit/main.rs')
-rw-r--r--src/bin/ngit/main.rs34
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
5use anyhow::Result; 5use anyhow::Result;
6use clap::Parser; 6use clap::Parser;
7use cli::{AccountCommands, Cli, Commands}; 7use cli::{AccountCommands, CUSTOMISE_TEMPLATE, Cli, Commands};
8 8
9mod cli; 9mod cli;
10use ngit::{cli_interactor, client, git, git_events, login, repo_ref}; 10use ngit::{cli_interactor, client, git, git_events, login, repo_ref};
@@ -14,14 +14,28 @@ mod sub_commands;
14#[tokio::main] 14#[tokio::main]
15async fn main() -> Result<()> { 15async 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}