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
mod init;
mod sim;
mod skills;
mod ui;
use clap::{Parser, Subcommand};
/// Simulate code usage, record everything and analyze the results
#[derive(Parser)]
#[command(name = "rngo", version)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
/// Initialize a directory for rngo
///
/// Creates a `.rngo` directory, a starter `.rngo/spec.yml`, and
/// updates `.gitignore`.
Init {
/// Directory to initialize
#[arg(long, default_value = ".")]
dir: std::path::PathBuf,
},
/// Run a simulation
///
/// Loads a spec, runs the simulation, routes events to systems,
/// and records everything.
Run {
/// Write events to stdout (instead of routing to systems)
#[arg(long)]
stdout: bool,
/// Path to a spec file (instead of building from the `.rngo` directory)
#[arg(long)]
spec: Option<std::path::PathBuf>,
/// Path to the `.rngo` directory
#[arg(long, default_value = ".")]
dir: std::path::PathBuf,
},
/// Manage rngo agent skills
Skills {
#[command(subcommand)]
command: SkillsCommands,
},
}
#[derive(Subcommand)]
enum SkillsCommands {
/// Download the latest rngo agent skills and install them
///
/// Idempotent: any previously installed `rngo-` skills in the target
/// directory are replaced with the latest release.
Install {
/// Where to install skills. Skips the interactive location prompt.
#[arg(long)]
path: Option<std::path::PathBuf>,
},
}
fn main() {
let cli = Cli::parse();
match cli.command {
Commands::Init { dir } => {
if let Err(e) = init::init(&dir) {
eprintln!("error: {e}");
std::process::exit(1);
}
}
Commands::Run { stdout, dir, spec } => match sim::run(&dir, stdout, spec.as_deref()) {
Ok(true) => {}
Ok(false) => std::process::exit(1),
Err(e) => {
eprintln!("error: {e}");
std::process::exit(1);
}
},
Commands::Skills { command } => match command {
SkillsCommands::Install { path } => {
if let Err(e) = skills::install(std::path::Path::new("."), path) {
eprintln!("error: {e}");
std::process::exit(1);
}
}
},
}
}