diff options
author | bryan newbold <bnewbold@robocracy.org> | 2023-03-04 15:51:42 -0800 |
---|---|---|
committer | bryan newbold <bnewbold@robocracy.org> | 2023-03-04 16:29:41 -0800 |
commit | 0c9b360d023027d3dfa364eb7627e6bfee322613 (patch) | |
tree | e4a0964dc7f8431493fcda7b61d257b3c5afc3e0 /adenosine-cli/src | |
parent | 0ea7cd1d360f2ef56ec4dad8ff316db6f2875ac0 (diff) | |
download | adenosine-0c9b360d023027d3dfa364eb7627e6bfee322613.tar.gz adenosine-0c9b360d023027d3dfa364eb7627e6bfee322613.zip |
cli: create-invite command
Diffstat (limited to 'adenosine-cli/src')
-rw-r--r-- | adenosine-cli/src/bin/adenosine.rs | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/adenosine-cli/src/bin/adenosine.rs b/adenosine-cli/src/bin/adenosine.rs index aae6a87..ae03a2c 100644 --- a/adenosine-cli/src/bin/adenosine.rs +++ b/adenosine-cli/src/bin/adenosine.rs @@ -57,6 +57,15 @@ struct Opt { )] auth_password: Option<String>, + /// Admin password in auth, if needed + #[structopt( + global = true, + long = "--admin-password", + env = "ATP_AUTH_ADMIN_PASSWORD", + hide_env_values = true + )] + admin_password: Option<String>, + /// Log more messages. Pass multiple times for ever more verbosity /// /// By default, it'll only report errors. Passing `-v` one time also prints @@ -115,12 +124,15 @@ enum AccountCommand { /// Fetches account metadata for the current session Info, // TODO: CreateRevocationKey or CreateDid + CreateInvite { + #[structopt(short = "-u", default_value = "1")] + uses: u64, + }, } #[derive(StructOpt)] enum RepoCommand { /// Get the current 'root' commit for a DID - /// Root { /// Repository DID, or uses the current session account did: Option<DidOrHost>, @@ -320,7 +332,11 @@ fn require_auth_did(opt: &Opt, xrpc_client: &mut XrpcClient) -> Result<Did> { } fn run(opt: Opt) -> Result<()> { - let mut xrpc_client = XrpcClient::new(opt.atp_host.clone(), opt.auth_token.clone())?; + let mut xrpc_client = XrpcClient::new( + opt.atp_host.clone(), + opt.auth_token.clone(), + opt.admin_password.clone(), + )?; let mut params: HashMap<String, String> = HashMap::new(); let jwt_did: Option<String> = if let Some(ref token) = opt.auth_token { Some(parse_did_from_jwt(token)?) @@ -534,6 +550,13 @@ fn run(opt: Opt) -> Result<()> { Command::Account { cmd: AccountCommand::Info, } => xrpc_client.get(&Nsid::from_str("com.atproto.account.get")?, None)?, + Command::Account { + cmd: AccountCommand::CreateInvite { uses }, + } => xrpc_client.post( + &Nsid::from_str("com.atproto.account.createInviteCode")?, + None, + Some(json!({ "useCount": uses })), + )?, Command::Repo { cmd: RepoCommand::Root { did }, } => { |