iquery/commands/
list_accessors.rsuse crate::commands::types::*;
use crate::types::Error;
use argh::{ArgsInfo, FromArgs};
use serde::Serialize;
use std::fmt;
#[derive(Default, ArgsInfo, FromArgs, PartialEq, Debug)]
#[argh(subcommand, name = "list-accessors")]
pub struct ListAccessorsCommand {}
impl Command for ListAccessorsCommand {
type Result = ListAccessorsResult;
async fn execute<P: DiagnosticsProvider>(self, provider: &P) -> Result<Self::Result, Error> {
let paths = provider.get_accessor_paths().await?;
Ok(ListAccessorsResult(paths))
}
}
#[derive(Serialize)]
pub struct ListAccessorsResult(Vec<String>);
impl fmt::Display for ListAccessorsResult {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for item in self.0.iter() {
writeln!(f, "{}", item)?;
}
Ok(())
}
}