#[cfg(feature = "json")]
use serde::Serialize;
#[derive(Debug, Clone)]
#[cfg_attr(feature = "json", derive(Serialize))]
pub struct CommandSpec {
pub name: &'static str,
pub description: &'static str,
pub syntax: &'static str,
pub arguments: &'static [ArgumentSpec], }
#[derive(Debug, Clone)]
#[cfg_attr(feature = "json", derive(Serialize))]
pub struct ArgumentSpec {
pub name: &'static str,
pub description: &'static str,
pub required: bool,
}
pub static SPECS: &[CommandSpec] = &[
CommandSpec {
name: "combine",
description: "Combines multiple numerical data series into a single series by averaging.",
syntax: "combine <series_1_path_or_data> <series_2_path_or_data> ... <series_n_path_or_data>",
arguments: &[
ArgumentSpec { name: "<series_data>", description: "Path to a data file or direct numerical data for a series. At least two series are required.", required: true },
],
},
CommandSpec {
name: "predict",
description: "Predicts the next numeric value based on linear extrapolation (2*last - second_last)",
syntax: "predict <number1> <number2> ... <numberN>",
arguments: &[
ArgumentSpec {
name: "<numbers>",
description: "A series of numbers. At least two numbers are required for prediction.",
required: true,
},
],
},
CommandSpec {
name: "show",
description: "Displays the logged commands and their outputs from the current session.",
syntax: "show",
arguments: &[],
},
CommandSpec {
name: "help",
description: "Displays this help message or detailed information about commands.",
syntax: "help [command_name] [--json]",
arguments: &[
ArgumentSpec { name: "[command_name]", description: "Optional: The name of a command to get detailed help for.", required: false },
ArgumentSpec { name: "--json", description: "Optional: Output the help information in JSON format.", required: false },
],
},
];
#[cfg(feature = "json")]
pub fn get_specs_json() -> Result<String, serde_json::Error> {
serde_json::to_string_pretty(&SPECS)
}