Skip to main content

skytool/
lib.rs

1#![allow(unused)]
2
3use std::str::FromStr;
4
5use clap::Parser;
6use miette::IntoDiagnostic;
7use tap::{Pipe, Tap};
8
9mod default;
10mod input;
11mod integrations;
12pub(crate) mod macros;
13mod ops;
14mod options;
15mod output;
16pub(crate) mod parse;
17mod patch;
18mod query;
19mod source;
20mod xrpc;
21
22pub mod transcode;
23
24pub async fn main() -> miette::Result<()> {
25  Command::parse().run().await.into_diagnostic()?;
26  Ok(())
27}
28
29pub(crate) trait Output: erased_serde::Serialize {}
30erased_serde::serialize_trait_object!(Output);
31
32impl crate::Output for () {}
33impl crate::Output for String {}
34impl<T> crate::Output for Vec<T> where T: crate::Output + serde::Serialize {}
35impl crate::Output for std::collections::BTreeMap<String, Box<dyn crate::Output>> {}
36impl crate::Output for schemars::schema::RootSchema {}
37impl crate::Output for bsky_sdk::agent::config::Config {}
38impl crate::Output for json_patch::Patch {}
39// impl crate::Output for serde_json::Value {}
40// impl crate::Output for serde_yml::Value {}
41
42#[derive(Debug, Clone, clap::Parser)]
43#[allow(clippy::large_enum_variant)]
44#[remain::sorted]
45#[command(about = "a commandline tool for bluesky/atproto and related operations")]
46pub(crate) enum Command {
47  Ops(ops::Command),
48  Xrpc(xrpc::Command),
49}
50
51crate::macros::impl_subcommand!(
52  (Command) => (run()) => {
53    ops,
54    xrpc
55  }
56);
57
58#[derive(Debug, thiserror::Error, miette::Diagnostic)]
59#[error(transparent)]
60pub(crate) enum Error {
61  Ops(#[from] ops::Error),
62  Keyring(#[from] keyring::Error),
63  Json(#[from] serde_json::Error),
64  Yaml(#[from] serde_yml::Error),
65  Io(#[from] std::io::Error),
66  #[error("missing authority")]
67  MissingAuthority,
68  #[error("missing password")]
69  MissingPassword,
70  Xrpc(#[from] xrpc::Error),
71}