upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs115
1 files changed, 115 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..e819b5a
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,115 @@
1use clap::{Parser, Subcommand};
2use nostr_sdk::Result;
3
4mod branch_refs;
5mod sub_commands;
6mod funcs;
7mod fetch_pull_push;
8mod groups;
9mod merge;
10mod pull_request;
11mod repos;
12mod patch;
13mod ngit_tag;
14mod kind;
15mod utils;
16mod config;
17mod repo_config;
18mod cli_helpers;
19
20/// Simple CLI application to use git through nostr
21#[derive(Parser)]
22#[command(name = "ngit")]
23#[command(author = "DanConwayDev <DanConwayDev@protonmail.com")]
24#[command(version = "0.0.1")]
25#[command(author, version, about, long_about = None)]
26struct Cli {
27 #[command(subcommand)]
28 command: Commands,
29 /// Relay to connect to
30 #[arg(short, long, action = clap::ArgAction::Append)]
31 relays: Vec<String>,
32}
33
34#[derive(Subcommand)]
35enum Commands {
36 /// Initialize a repoistory
37 Clone(sub_commands::clone::CloneSubCommand),
38 /// Initialize a repoistory
39 Init(sub_commands::init::InitSubCommand),
40 /// Pull to events and relays
41 Pull(sub_commands::pull::PullSubCommand),
42 /// Push to events and relays
43 Push(sub_commands::push::PushSubCommand),
44 /// Merge to events and relays
45 Merge(sub_commands::merge::MergeSubCommand),
46 /// Fetch from relays
47 Fetch(sub_commands::fetch::FetchSubCommand),
48 /// View active PRs from relays
49 Prs(sub_commands::prs::PrsSubCommand),
50 /// rebroadcast all repository events
51 Rebroadcast(sub_commands::rebroadcast::RebroadcastSubCommand),
52 ChangeUser(sub_commands::change_user::ChangeUserSubCommand),
53}
54
55fn main() -> Result<()> {
56 println!("ngit prototype v0.0.1-alpha");
57 // Parse input
58 let args: Cli = Cli::parse();
59
60 // Post event
61 match &args.command {
62 Commands::Init(sub_command_args) => sub_commands::init::create_and_broadcast_init(
63 args.relays,
64 sub_command_args,
65 ),
66 Commands::Clone(sub_command_args) => {
67 sub_commands::clone::clone_from_relays(
68 args.relays,
69 sub_command_args,
70 );
71 Ok(())
72 },
73 Commands::Pull(sub_command_args) => {
74 sub_commands::pull::pull_from_relays(
75 None,
76 sub_command_args,
77 );
78 Ok(())
79 },
80 Commands::Push(sub_command_args) => {
81 sub_commands::push::push(
82 sub_command_args,
83 );
84 Ok(())
85 }
86 Commands::Merge(sub_command_args) => {
87 sub_commands::merge::merge(
88 sub_command_args,
89 );
90 Ok(())
91 }
92 Commands::Fetch(_sub_command_args) => {
93 sub_commands::fetch::fetch_from_relays(None);
94 Ok(())
95 },
96 Commands::Prs(sub_command_args) => {
97 sub_commands::prs::prs(
98 sub_command_args,
99 );
100 Ok(())
101 }
102 Commands::Rebroadcast(sub_command_args) => {
103 sub_commands::rebroadcast::rebroadcast(
104 sub_command_args,
105 );
106 Ok(())
107 }
108 Commands::ChangeUser(sub_command_args) => {
109 sub_commands::change_user::change_user(
110 sub_command_args,
111 );
112 Ok(())
113 }
114 }
115}