aboutsummaryrefslogtreecommitdiffstats
path: root/adenosine-cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'adenosine-cli/src')
-rw-r--r--adenosine-cli/src/bin/adenosine.rs105
-rw-r--r--adenosine-cli/src/pretty.rs6
2 files changed, 67 insertions, 44 deletions
diff --git a/adenosine-cli/src/bin/adenosine.rs b/adenosine-cli/src/bin/adenosine.rs
index 7f81191..6900b20 100644
--- a/adenosine-cli/src/bin/adenosine.rs
+++ b/adenosine-cli/src/bin/adenosine.rs
@@ -122,7 +122,6 @@ enum AccountCommand {
/// Deletes the current login session
Logout,
/// Fetches account metadata for the current session
- Info,
// TODO: CreateRevocationKey or CreateDid
CreateInvite {
#[structopt(short = "-u", default_value = "1")]
@@ -133,7 +132,7 @@ enum AccountCommand {
#[derive(StructOpt)]
enum RepoCommand {
/// Get the current 'root' commit for a DID
- Root {
+ Head {
/// Repository DID, or uses the current session account
did: Option<DidOrHost>,
},
@@ -371,15 +370,21 @@ fn run(opt: Opt) -> Result<()> {
.as_ref()
.map(|v| v.to_string())
.unwrap_or(require_auth_did(&opt, &mut xrpc_client)?.to_string());
- params.insert("user".to_string(), name);
- xrpc_client.get(&Nsid::from_str("com.atproto.repo.describe")?, Some(params))?
+ params.insert("repo".to_string(), name);
+ xrpc_client.get(
+ &Nsid::from_str("com.atproto.repo.describeRepo")?,
+ Some(params),
+ )?
}
Command::Resolve { name } => {
- params.insert("name".to_string(), name.to_string());
- xrpc_client.get(&Nsid::from_str("com.atproto.handle.resolve")?, Some(params))?
+ params.insert("handle".to_string(), name.to_string());
+ xrpc_client.get(
+ &Nsid::from_str("com.atproto.identity.resolveHandle")?,
+ Some(params),
+ )?
}
Command::Get { uri, cid } => {
- params.insert("user".to_string(), uri.repository.to_string());
+ params.insert("repo".to_string(), uri.repository.to_string());
params.insert(
"collection".to_string(),
uri.collection.ok_or(anyhow!("collection required"))?,
@@ -395,12 +400,15 @@ fn run(opt: Opt) -> Result<()> {
}
Command::Ls { uri } => {
// TODO: option to print fully-qualified path?
- params.insert("user".to_string(), uri.repository.to_string());
+ params.insert("repo".to_string(), uri.repository.to_string());
if uri.collection.is_none() {
// if a repository, but no collection, list the collections
let describe = xrpc_client
- .get(&Nsid::from_str("com.atproto.repo.describe")?, Some(params))?
- .ok_or(anyhow!("expected a repo.describe response"))?;
+ .get(
+ &Nsid::from_str("com.atproto.repo.describeRepo")?,
+ Some(params),
+ )?
+ .ok_or(anyhow!("expected a repo.describeRepo response"))?;
for c in describe["collections"]
.as_array()
.ok_or(anyhow!("expected collection list"))?
@@ -439,7 +447,7 @@ fn run(opt: Opt) -> Result<()> {
&Nsid::from_str("com.atproto.repo.createRecord")?,
None,
Some(json!({
- "did": did,
+ "repo": did,
"collection": collection,
// TODO: "validate" (boolean)
"record": val
@@ -457,7 +465,7 @@ fn run(opt: Opt) -> Result<()> {
.clone()
.ok_or(anyhow!("collection required"))?;
let rkey = uri.record.clone().ok_or(anyhow!("record key required"))?;
- params.insert("did".to_string(), did.clone());
+ params.insert("repo".to_string(), did.clone());
params.insert("collection".to_string(), collection.clone());
params.insert("rkey".to_string(), rkey.clone());
// fetch existing, extend map with fields, put the updated value
@@ -469,7 +477,7 @@ fn run(opt: Opt) -> Result<()> {
&Nsid::from_str("com.atproto.repo.putRecord")?,
None,
Some(json!({
- "did": did,
+ "repo": did,
"collection": collection,
"rkey": rkey,
"record": record,
@@ -488,7 +496,7 @@ fn run(opt: Opt) -> Result<()> {
&Nsid::from_str("com.atproto.repo.deleteRecord")?,
None,
Some(json!({
- "did": did,
+ "repo": did,
"collection": collection,
"rkey": rkey,
})),
@@ -531,7 +539,7 @@ fn run(opt: Opt) -> Result<()> {
body["inviteCode"] = json!(code);
}
xrpc_client.post(
- &Nsid::from_str("com.atproto.account.create")?,
+ &Nsid::from_str("com.atproto.server.createAccount")?,
None,
Some(body),
)?
@@ -539,7 +547,7 @@ fn run(opt: Opt) -> Result<()> {
Command::Account {
cmd: AccountCommand::Login { handle, password },
} => xrpc_client.post(
- &Nsid::from_str("com.atproto.session.create")?,
+ &Nsid::from_str("com.atproto.server.createSession")?,
None,
Some(json!({
"handle": handle,
@@ -548,25 +556,34 @@ fn run(opt: Opt) -> Result<()> {
)?,
Command::Account {
cmd: AccountCommand::Refresh,
- } => xrpc_client.post(&Nsid::from_str("com.atproto.session.refresh")?, None, None)?,
+ } => xrpc_client.post(
+ &Nsid::from_str("com.atproto.server.refreshSession")?,
+ None,
+ None,
+ )?,
Command::Account {
cmd: AccountCommand::Logout,
- } => xrpc_client.post(&Nsid::from_str("com.atproto.session.delete")?, None, None)?,
+ } => xrpc_client.post(
+ &Nsid::from_str("com.atproto.server.deleteSession")?,
+ None,
+ None,
+ )?,
Command::Account {
cmd: AccountCommand::Delete,
- } => xrpc_client.post(&Nsid::from_str("com.atproto.account.delete")?, None, None)?,
- Command::Account {
- cmd: AccountCommand::Info,
- } => xrpc_client.get(&Nsid::from_str("com.atproto.account.get")?, None)?,
+ } => xrpc_client.post(
+ &Nsid::from_str("com.atproto.server.deleteAccount")?,
+ None,
+ None,
+ )?,
Command::Account {
cmd: AccountCommand::CreateInvite { uses },
} => xrpc_client.post(
- &Nsid::from_str("com.atproto.account.createInviteCode")?,
+ &Nsid::from_str("com.atproto.server.createInviteCode")?,
None,
Some(json!({ "useCount": uses })),
)?,
Command::Repo {
- cmd: RepoCommand::Root { did },
+ cmd: RepoCommand::Head { did },
} => {
let did = match did {
Some(DidOrHost::Host(_)) => return Err(anyhow!("expected a DID, not a hostname")),
@@ -574,7 +591,7 @@ fn run(opt: Opt) -> Result<()> {
None => jwt_did.ok_or(anyhow!("expected a DID"))?,
};
params.insert("did".to_string(), did);
- xrpc_client.get(&Nsid::from_str("com.atproto.sync.getRoot")?, Some(params))?
+ xrpc_client.get(&Nsid::from_str("com.atproto.sync.getHead")?, Some(params))?
}
Command::Repo {
cmd: RepoCommand::Export { did, from },
@@ -617,7 +634,7 @@ fn run(opt: Opt) -> Result<()> {
.as_ref()
.map(|v| v.to_string())
.unwrap_or(require_auth_did(&opt, &mut xrpc_client)?.to_string());
- params.insert("author".to_string(), name);
+ params.insert("actor".to_string(), name);
let resp = xrpc_client.get(
&Nsid::from_str("app.bsky.feed.getAuthorFeed")?,
Some(params),
@@ -630,7 +647,7 @@ fn run(opt: Opt) -> Result<()> {
.iter()
{
let val: serde_json::Value = val.clone();
- let fi: app_bsky::FeedPostView = serde_json::from_value(val)?;
+ let fi: app_bsky::FeedViewPost = serde_json::from_value(val)?;
pretty::pp_feed_post_view(&fi)?;
}
None
@@ -652,7 +669,7 @@ fn run(opt: Opt) -> Result<()> {
{
let val: serde_json::Value = val.clone();
//print_result_json(Some(val.clone()))?;
- let fi: app_bsky::FeedPostView = serde_json::from_value(val)?;
+ let fi: app_bsky::FeedViewPost = serde_json::from_value(val)?;
pretty::pp_feed_post_view(&fi)?;
}
None
@@ -677,7 +694,7 @@ fn run(opt: Opt) -> Result<()> {
resp["thread"]
.as_object()
.ok_or(anyhow!("expected thread from getPostThread"))?;
- let tpv: app_bsky::ThreadPostView = serde_json::from_value(resp["thread"].clone())?;
+ let tpv: app_bsky::ThreadViewPost = serde_json::from_value(resp["thread"].clone())?;
pretty::pp_thread_post_view(&tpv)?;
None
} else {
@@ -688,7 +705,10 @@ fn run(opt: Opt) -> Result<()> {
cmd: BskyCommand::Notifications,
} => {
require_auth_did(&opt, &mut xrpc_client)?;
- xrpc_client.get(&Nsid::from_str("app.bsky.notification.list")?, None)?
+ xrpc_client.get(
+ &Nsid::from_str("app.bsky.notification.listNotifications")?,
+ None,
+ )?
}
Command::Bsky {
cmd: BskyCommand::Post { ref text },
@@ -698,7 +718,7 @@ fn run(opt: Opt) -> Result<()> {
&Nsid::from_str("com.atproto.repo.createRecord")?,
None,
Some(json!({
- "did": did,
+ "repo": did,
"collection": "app.bsky.feed.post",
"record": {
"text": text,
@@ -711,7 +731,7 @@ fn run(opt: Opt) -> Result<()> {
cmd: BskyCommand::Repost { ref uri },
} => {
let did = require_auth_did(&opt, &mut xrpc_client)?;
- params.insert("user".to_string(), uri.repository.to_string());
+ params.insert("repo".to_string(), uri.repository.to_string());
params.insert(
"collection".to_string(),
uri.collection
@@ -732,7 +752,7 @@ fn run(opt: Opt) -> Result<()> {
&Nsid::from_str("com.atproto.repo.createRecord")?,
None,
Some(json!({
- "did": did,
+ "repo": did,
"collection": "app.bsky.feed.repost",
"record": {
"subject": {
@@ -748,7 +768,7 @@ fn run(opt: Opt) -> Result<()> {
cmd: BskyCommand::Like { ref uri },
} => {
let did = require_auth_did(&opt, &mut xrpc_client)?;
- params.insert("user".to_string(), uri.repository.to_string());
+ params.insert("repo".to_string(), uri.repository.to_string());
params.insert(
"collection".to_string(),
uri.collection
@@ -769,11 +789,10 @@ fn run(opt: Opt) -> Result<()> {
&Nsid::from_str("com.atproto.repo.createRecord")?,
None,
Some(json!({
- "did": did,
- "collection": "app.bsky.feed.vote",
+ "repo": did,
+ "collection": "app.bsky.feed.like",
"record": {
"subject": { "uri": uri.to_string(), "cid": cid },
- "direction": "up",
"createdAt": created_at_now(),
},
})),
@@ -787,7 +806,7 @@ fn run(opt: Opt) -> Result<()> {
&Nsid::from_str("com.atproto.repo.createRecord")?,
None,
Some(json!({
- "did": did,
+ "repo": did,
"collection": "app.bsky.graph.follow",
"record": {
"subject": { "did": uri.to_string() },
@@ -807,10 +826,14 @@ fn run(opt: Opt) -> Result<()> {
xrpc_client.get(&Nsid::from_str("app.bsky.actor.getProfile")?, Some(params))?
}
Command::Bsky {
- cmd: BskyCommand::SearchUsers { query },
+ cmd: BskyCommand::SearchUsers { ref query },
} => {
- params.insert("term".to_string(), query);
- xrpc_client.get(&Nsid::from_str("app.bsky.actor.search")?, Some(params))?
+ require_auth_did(&opt, &mut xrpc_client)?;
+ params.insert("term".to_string(), query.to_string());
+ xrpc_client.get(
+ &Nsid::from_str("app.bsky.actor.searchActors")?,
+ Some(params),
+ )?
}
};
print_result_json(result)?;
diff --git a/adenosine-cli/src/pretty.rs b/adenosine-cli/src/pretty.rs
index 764a46f..a3cb5d6 100644
--- a/adenosine-cli/src/pretty.rs
+++ b/adenosine-cli/src/pretty.rs
@@ -1,9 +1,9 @@
-use adenosine::app_bsky::{FeedPostView, PostView, ThreadPostView};
+use adenosine::app_bsky::{FeedViewPost, PostView, ThreadViewPost};
use anyhow::Result;
use std::io::Write;
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
-pub fn pp_thread_post_view(tpv: &ThreadPostView) -> Result<()> {
+pub fn pp_thread_post_view(tpv: &ThreadViewPost) -> Result<()> {
// TODO: this could do better
if let Some(parent) = &tpv.parent {
pp_thread_post_view(parent)?;
@@ -31,7 +31,7 @@ pub fn pp_thread_post_view(tpv: &ThreadPostView) -> Result<()> {
Ok(())
}
-pub fn pp_feed_post_view(fpv: &FeedPostView) -> Result<()> {
+pub fn pp_feed_post_view(fpv: &FeedViewPost) -> Result<()> {
let mut stdout = StandardStream::stdout(ColorChoice::Always);
if let Some(repost) = &fpv.reason {