sapphire_sync_cli/cli.rs
1//! CLI-shell types: the command line both editions run.
2
3use clap::{Parser, Subcommand};
4
5// The framework's command enum, re-exported so the tests' `use cli::…` reads
6// the same surface `run` sees through `sapphire_sync_core`.
7pub use sapphire_sync_core::framework::server::FrameworkCommand;
8
9/// The command line of the headless edition's `sapphire-sync` binary.
10///
11/// A bare invocation prints the help; the service manager starts the binary
12/// with `serve`. The desktop app parses the same [`AppCommand`], with a bare
13/// invocation opening its window instead.
14#[derive(Parser)]
15#[command(
16 name = "sapphire-sync",
17 arg_required_else_help = true,
18 version,
19 about = "P2P file sync over sapphire-framework"
20)]
21pub struct Cli {
22 /// The app's own verbs, beside the framework's.
23 #[command(subcommand)]
24 pub app: AppCommand,
25}
26
27/// The command line's top level: the app's own verbs and the framework's, flat.
28#[derive(Debug, Subcommand)]
29pub enum AppCommand {
30 /// Workspace sync controls: `sync disable`.
31 Sync(SyncCommand),
32 /// The framework's verbs, flattened in.
33 #[command(flatten)]
34 Framework(FrameworkCommand),
35}
36
37/// The app's own `sync` verb group: `sync disable`, no more.
38#[derive(Debug, clap::Args)]
39pub struct SyncCommand {
40 /// The verb itself.
41 #[command(subcommand)]
42 pub command: SyncSubcommand,
43}
44
45/// The `sync` verbs.
46#[derive(Debug, Subcommand)]
47pub enum SyncSubcommand {
48 /// Stop syncing the server's workspace (refused from inside another one).
49 ///
50 /// Files and the sync-id stay; re-enabling via `workspace init --sync`
51 /// rejoins the same workspace.
52 Disable,
53}