-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
622 additions
and
42 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
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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use clap::Parser; | ||
use futures::StreamExt; | ||
use iroh::rpc_protocol::{AuthorCreateRequest, AuthorListRequest}; | ||
|
||
use super::RpcClient; | ||
|
||
#[derive(Debug, Clone, Parser)] | ||
pub enum Commands { | ||
Author { | ||
#[clap(subcommand)] | ||
command: Author, | ||
}, | ||
} | ||
|
||
impl Commands { | ||
pub async fn run(self, client: RpcClient) -> anyhow::Result<()> { | ||
match self { | ||
Commands::Author { command } => command.run(client).await, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, Parser)] | ||
pub enum Author { | ||
List, | ||
Create, | ||
// Import { | ||
// key: String, | ||
// }, | ||
// Share { | ||
// mode: ShareMode, | ||
// author_id: AuthorId, | ||
// }, | ||
} | ||
|
||
impl Author { | ||
pub async fn run(self, client: RpcClient) -> anyhow::Result<()> { | ||
match self { | ||
Author::List => { | ||
let mut stream = client.server_streaming(AuthorListRequest {}).await?; | ||
while let Some(author) = stream.next().await { | ||
println!("{}", author??.author_id); | ||
} | ||
} | ||
Author::Create => { | ||
let author = client.rpc(AuthorCreateRequest).await??; | ||
println!("{}", author.author_id); | ||
} | ||
// Commands::AuthorImport { key } => todo!(), | ||
// Commands::AuthorShare { mode, author_id } => todo!(), | ||
} | ||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.