1use crate::ast::{Arg, StepKind};
2use anyhow::Result;
3
4pub struct ArgSpec {
6 pub name: &'static str,
7 pub arg_type: &'static str,
8 pub description: &'static str,
9 pub io: IoDirection,
10 pub index: usize,
11 pub required: bool,
12 pub fallback_stream: Option<Stream>,
13}
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub enum IoDirection {
18 Read,
19 Write,
20}
21
22#[derive(Debug, Clone, Copy, PartialEq, Eq)]
24pub enum Stream {
25 Stdin,
26 Stdout,
27 Stderr,
28}
29
30pub struct FlagSpec {
32 pub name: &'static str,
33 pub long: &'static str,
34 pub value_type: FlagValueType,
35 pub required: bool,
36 pub description: &'static str,
37}
38
39#[derive(Debug, Clone, Copy, PartialEq, Eq)]
41pub enum FlagValueType {
42 Flag,
44 String,
46 Int,
48}
49
50pub struct CommandMeta {
52 pub name: &'static str,
53 pub syntax: &'static str,
54 pub summary: &'static str,
55 pub description: &'static str,
56 pub args: &'static [ArgSpec],
57 pub flags: &'static [FlagSpec],
58 pub default_output: Option<Stream>,
59 pub examples: &'static [Example],
60}
61
62pub struct Example {
64 pub name: &'static str,
65 pub fence_meta: Option<&'static str>,
66 pub code: &'static str,
67}
68
69pub trait CommandSpec {
75 const NAME: &'static str;
76
77 fn metadata() -> CommandMeta;
78 fn lower(flags: Vec<(String, Arg)>, args: Vec<Arg>) -> Result<StepKind>;
79}