iquery/commands/
list_accessors.rs1use crate::commands::types::*;
6use crate::types::Error;
7use argh::{ArgsInfo, FromArgs};
8use serde::Serialize;
9use std::fmt;
10
11#[derive(Default, ArgsInfo, FromArgs, PartialEq, Debug)]
14#[argh(subcommand, name = "list-accessors")]
15pub struct ListAccessorsCommand {}
16
17impl Command for ListAccessorsCommand {
18 type Result = ListAccessorsResult;
19
20 async fn execute<P: DiagnosticsProvider>(self, provider: &P) -> Result<Self::Result, Error> {
21 let paths = provider.get_accessor_paths().await?;
22 Ok(ListAccessorsResult(paths))
23 }
24}
25
26#[derive(Serialize)]
27pub struct ListAccessorsResult(Vec<String>);
28
29impl fmt::Display for ListAccessorsResult {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 for item in self.0.iter() {
32 writeln!(f, "{}", item)?;
33 }
34 Ok(())
35 }
36}