use std::path::PathBuf;
use clap::{Parser, Subcommand};
use mobius_gateway::client::Endpoint;
#[derive(Debug, Parser)]
#[command(
name = "mobius",
version,
propagate_version = true,
about = "Terminal client for a möbius gateway"
)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Command>,
}
#[derive(Debug, Subcommand)]
pub enum Command {
Run {
bot: String,
task_file: PathBuf,
},
Pair {
endpoint: Endpoint,
one_time_code: String,
},
Extensions,
}
#[cfg(test)]
mod tests {
use clap::CommandFactory as _;
use super::*;
#[test]
fn command_definition_is_valid() {
Cli::command().debug_assert();
}
#[test]
fn run_parses_a_bot_and_task_file() {
let cli = Cli::try_parse_from(["mobius", "run", "@builder", "task.md"])
.expect("parse run command");
assert!(matches!(
cli.command,
Some(Command::Run { bot, task_file })
if bot == "@builder" && task_file == std::path::Path::new("task.md")
));
}
}