1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! Declarative command-line syntax.
use std::path::PathBuf;
use clap::{Parser, Subcommand, ValueEnum};
#[derive(Debug, Parser)]
#[command(
name = "ferrosift",
about = "Deterministic local-first data transformation",
disable_help_subcommand = true
)]
pub struct Args {
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
pub enum Command {
/// List canonical built-in operation identifiers.
Operations {
/// Listing format.
#[arg(long, value_enum, default_value_t = CatalogFormat::Plain)]
format: CatalogFormat,
},
/// Describe one canonical operation as JSON.
Describe {
/// Canonical versioned operation identifier.
operation: String,
},
/// Validate a recipe without invoking its operations.
Validate {
/// Serialized recipe format.
#[arg(long, value_enum)]
format: RecipeFormat,
/// Representation supplied to the first recipe step.
#[arg(long, value_enum)]
input_kind: InputKind,
/// Recipe path, or '-' for standard input.
#[arg(long)]
recipe: PathBuf,
},
/// Execute a recipe under fixed resource ceilings.
Run {
/// Serialized recipe format.
#[arg(long, value_enum)]
format: RecipeFormat,
/// Representation supplied to the first recipe step.
#[arg(long, value_enum)]
input_kind: InputKind,
/// Recipe path, or '-' for standard input.
#[arg(long)]
recipe: PathBuf,
/// Input path, or '-' for standard input.
#[arg(long)]
input: PathBuf,
/// Output path, or '-' for standard output.
#[arg(long, default_value = "-")]
output: PathBuf,
},
}
/// How `operations` renders the catalog.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, ValueEnum)]
pub enum CatalogFormat {
/// One canonical identifier per line.
#[default]
Plain,
/// One JSON object per operation, with compatibility aliases.
Json,
}
#[derive(Clone, Copy, Debug, ValueEnum)]
pub enum RecipeFormat {
/// `FerroSift`'s versioned portable recipe JSON.
#[value(name = "ferrosift")]
FerroSift,
/// `CyberChef` 11.3 compact recipe JSON.
#[value(name = "cyberchef-v11.3")]
CyberChefV11_3,
/// `CyberChef` 11.4 compact recipe JSON.
///
/// The same shape as 11.3 — the reference's whole recipe model is
/// unchanged between the two — so this selects which operation *names*
/// resolve. A recipe using an operation 11.4 introduced loads here and not
/// as 11.3, which is a fact about the reference rather than about this
/// port.
#[value(name = "cyberchef-v11.4")]
CyberChefV11_4,
}
#[derive(Clone, Copy, Debug, ValueEnum)]
pub enum InputKind {
/// Uninterpreted input bytes.
Bytes,
/// Strict UTF-8 text input.
Text,
}