///|
/// CLI-level failure for the fixed runner command-line contract.
pub(all) suberror RunnerCliError {
RunnerCliError(String)
} derive(Debug)
///|
pub fn RunnerCliError::message(self : RunnerCliError) -> String {
match self {
RunnerCliError(message) => message
}
}
///|
/// Parse the fixed runner CLI contract: positional inputs and one `-o` value.
pub fn parse_runner_cli(
argv : ArrayView[String],
) -> GenerationPlan raise RunnerCliError {
let matches = runner_cli_command().parse(argv~, env={}) catch {
err => raise RunnerCliError::RunnerCliError(err.to_string())
}
let (input_paths, output_path) = match
(matches.values.get("input"), matches.values.get("output")) {
(Some(inputs), Some([output])) => (inputs, output)
_ =>
raise RunnerCliError::RunnerCliError(
"expected at least one input path and exactly one -o value",
)
}
GenerationPlan::{ input_paths, output_path }
}
///|
fn runner_cli_command() -> @argparse.Command {
@argparse.Command(
"mproc-gen",
options=[@argparse.OptionArg("output", short='o', long="", required=true)],
positionals=[
@argparse.PositionArg("input", num_args=@argparse.ValueRange(lower=1)),
],
disable_help_flag=true,
disable_version_flag=true,
disable_help_subcommand=true,
)
}