use crate::ast::{Arg, StepKind};
use anyhow::Result;
pub struct ArgSpec {
pub name: &'static str,
pub arg_type: &'static str,
pub description: &'static str,
pub io: IoDirection,
pub index: usize,
pub required: bool,
pub fallback_stream: Option<Stream>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum IoDirection {
Read,
Write,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Stream {
Stdin,
Stdout,
Stderr,
}
pub struct FlagSpec {
pub name: &'static str,
pub long: &'static str,
pub value_type: FlagValueType,
pub required: bool,
pub description: &'static str,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FlagValueType {
Flag,
String,
Int,
}
pub struct CommandMeta {
pub name: &'static str,
pub syntax: &'static str,
pub summary: &'static str,
pub description: &'static str,
pub args: &'static [ArgSpec],
pub flags: &'static [FlagSpec],
pub default_output: Option<Stream>,
pub examples: &'static [Example],
}
pub struct Example {
pub name: &'static str,
pub fence_meta: Option<&'static str>,
pub code: &'static str,
}
pub trait CommandSpec {
const NAME: &'static str;
fn metadata() -> CommandMeta;
fn lower(flags: Vec<(String, Arg)>, args: Vec<Arg>) -> Result<StepKind>;
}