Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nostrs: Add text_note create command
- Loading branch information
Showing
3 changed files
with
31 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,39 @@ | ||
pub mod client; | ||
mod client; | ||
mod config; | ||
mod handler; | ||
|
||
#[derive(clap::Parser)] | ||
#[command(version, about, long_about = None)] | ||
struct Command { | ||
#[command(subcommand)] | ||
subcommand: Subcommand, | ||
resource: Resource, | ||
} | ||
|
||
#[derive(clap::Subcommand)] | ||
enum Subcommand { | ||
enum Resource { | ||
Metadata, | ||
TextNote, | ||
TextNote { | ||
#[command(subcommand)] | ||
command: TextNoteCommand, | ||
}, | ||
Timeline, | ||
} | ||
|
||
#[derive(clap::Subcommand)] | ||
enum TextNoteCommand { | ||
Create { content: String }, | ||
List, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> anyhow::Result<()> { | ||
let command = <Command as clap::Parser>::parse(); | ||
match command.subcommand { | ||
Subcommand::Metadata => handler::metadata::handle().await, | ||
Subcommand::TextNote => handler::text_note::handle().await, | ||
Subcommand::Timeline => handler::timeline::handle().await, | ||
match command.resource { | ||
Resource::Metadata => handler::metadata::handle().await, | ||
Resource::TextNote { command } => match command { | ||
TextNoteCommand::Create { content } => handler::text_note::create(content).await, | ||
TextNoteCommand::List => handler::text_note::list().await, | ||
}, | ||
Resource::Timeline => handler::timeline::handle().await, | ||
} | ||
} |