1use std::path::PathBuf;
4
5use clap::{Parser, Subcommand};
6use mobius_gateway::client::Endpoint;
7
8#[derive(Debug, Parser)]
10#[command(
11 name = "mobius",
12 version,
13 propagate_version = true,
14 about = "Terminal client for a möbius gateway"
15)]
16pub struct Cli {
17 #[command(subcommand)]
19 pub command: Option<Command>,
20}
21
22#[derive(Debug, Subcommand)]
24pub enum Command {
25 Run {
27 bot: String,
29
30 task_file: PathBuf,
32 },
33
34 Pair {
36 endpoint: Endpoint,
38
39 one_time_code: String,
41 },
42
43 Extensions,
45}
46
47#[cfg(test)]
48mod tests {
49 use clap::CommandFactory as _;
50
51 use super::*;
52
53 #[test]
54 fn command_definition_is_valid() {
55 Cli::command().debug_assert();
56 }
57
58 #[test]
59 fn run_parses_a_bot_and_task_file() {
60 let cli = Cli::try_parse_from(["mobius", "run", "@builder", "task.md"])
61 .expect("parse run command");
62
63 assert!(matches!(
64 cli.command,
65 Some(Command::Run { bot, task_file })
66 if bot == "@builder" && task_file == std::path::Path::new("task.md")
67 ));
68 }
69}