diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2023-09-01 00:00:00 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2023-09-13 09:24:49 +0000 |
| commit | 6423baebd92e45c9be85157c443dff42e65d8d14 (patch) | |
| tree | 6548edfd80d0cd9d1267378ebe816ec95e394137 /src/main.rs | |
| parent | 5c5feaa732363e32e2a980a887fa42b4394b1a5e (diff) | |
refactor: rebuild app skeleton
Create skeleton for a complete rebuild of the prototype as a production
ready product.
Includes design patterns for:
- dependency injection
- unit testing with dependency mocking
- integration testing
- error handling
- config storage
BREAKING-CHANGE: ground-up redesign with incompatible protocol standards
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..d16f1a3 --- /dev/null +++ b/src/main.rs | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | #![cfg_attr(not(test), warn(clippy::pedantic))] | ||
| 2 | #![cfg_attr(not(test), warn(clippy::expect_used))] | ||
| 3 | |||
| 4 | use anyhow::Result; | ||
| 5 | use clap::{Parser, Subcommand}; | ||
| 6 | |||
| 7 | mod cli_interactor; | ||
| 8 | mod config; | ||
| 9 | mod key_handling; | ||
| 10 | mod login; | ||
| 11 | mod sub_commands; | ||
| 12 | |||
| 13 | #[derive(Parser)] | ||
| 14 | #[command(author, version, about, long_about = None)] | ||
| 15 | #[command(propagate_version = true)] | ||
| 16 | pub struct Cli { | ||
| 17 | #[command(subcommand)] | ||
| 18 | command: Commands, | ||
| 19 | /// nsec or hex private key | ||
| 20 | #[arg(short, long)] | ||
| 21 | nsec: Option<String>, | ||
| 22 | } | ||
| 23 | |||
| 24 | #[derive(Subcommand)] | ||
| 25 | enum Commands { | ||
| 26 | /// save encrypted nsec for future use | ||
| 27 | Login(sub_commands::login::SubCommandArgs), | ||
| 28 | } | ||
| 29 | |||
| 30 | fn main() -> Result<()> { | ||
| 31 | let cli = Cli::parse(); | ||
| 32 | match &cli.command { | ||
| 33 | Commands::Login(args) => sub_commands::login::launch(&cli, args), | ||
| 34 | } | ||
| 35 | } | ||