feat: add --output-format option for json/yaml support in info/status/list modes
Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
19
src/main.rs
19
src/main.rs
@@ -11,6 +11,7 @@ use directories::ProjectDirs;
|
||||
extern crate prettytable;
|
||||
|
||||
use std::str::FromStr;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
extern crate lazy_static;
|
||||
|
||||
@@ -21,6 +22,9 @@ pub mod meta_plugin;
|
||||
//pub mod item;
|
||||
|
||||
extern crate term;
|
||||
extern crate serde_json;
|
||||
extern crate serde_yaml;
|
||||
extern crate serde;
|
||||
|
||||
/**
|
||||
* Main struct for command-line arguments.
|
||||
@@ -105,6 +109,7 @@ struct ItemArgs {
|
||||
meta_plugins: Vec<String>,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Struct for general options.
|
||||
*/
|
||||
@@ -133,6 +138,10 @@ struct OptionsArgs {
|
||||
#[arg(short, long)]
|
||||
#[arg(help("Do not show any messages"))]
|
||||
quiet: bool,
|
||||
|
||||
#[arg(long, value_enum, default_value("table"))]
|
||||
#[arg(help("Output format (only works with --info, --status, --list)"))]
|
||||
output_format: Option<String>,
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,6 +261,16 @@ fn main() -> Result<(), Error> {
|
||||
}
|
||||
}
|
||||
|
||||
// Validate output format usage
|
||||
if let Some(output_format_str) = &args.options.output_format {
|
||||
if output_format_str != "table" && mode != KeepModes::Info && mode != KeepModes::Status && mode != KeepModes::List {
|
||||
cmd.error(
|
||||
ErrorKind::InvalidValue,
|
||||
"--output-format can only be used with --info, --status, or --list modes"
|
||||
).exit();
|
||||
}
|
||||
}
|
||||
|
||||
debug!("MAIN: args: {:?}", args);
|
||||
debug!("MAIN: ids: {:?}", ids);
|
||||
debug!("MAIN: tags: {:?}", tags);
|
||||
|
||||
Reference in New Issue
Block a user