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
//! CLI subcommands for plugins.
//!
//! # Registering commands (`cli.rs`)
//!
//! Plugins contribute Clap subcommands via [`CommandRegistrar`](crate::command::CommandRegistrar).
//! The users plugin ships `createsuperuser`, `changepassword`, and `revalidate_users` as examples.
//!
//! ```ignore
//! use clap::Parser;
//! use lariv_rs::command::{CommandCapability, CommandRegistrar, RunCommand};
//!
//! #[derive(Parser, Debug)]
//! pub struct GreetArgs {
//! #[arg(long, default_value = "Developer")]
//! name: String,
//! }
//!
//! pub struct GreetCommand;
//!
//! #[async_trait::async_trait]
//! impl<M> RunCommand<M> for GreetCommand {
//! type Args = GreetArgs;
//!
//! async fn run(args: Self::Args, _app: MountedApp<M>) -> anyhow::Result<()> {
//! println!("Hello, {}!", args.name);
//! Ok(())
//! }
//! }
//!
//! pub struct Hook;
//!
//! impl CommandRegistrar for Hook {
//! fn register_commands(self, cap: CommandCapability) -> CommandCapability {
//! cap.register("greet", GreetCommand)
//! }
//! }
//! ```
//!
//! Add `commands(cli::Hook)` to install steps.
//!
//! # Running commands
//!
//! ```text
//! cargo run -- greet --name Alice
//! cargo run -- migrate
//! cargo run -- seed
//! cargo run -- serve # default when no subcommand given
//! ```
//!
//! Built-in commands:
//!
//! | Command | Purpose |
//! |---------|---------|
//! | `serve` | Start the HTTP server |
//! | `migrate` | Apply SeaORM migrations |
//! | `seed` | Run startup seed hooks |
//!
//! Plugin commands are merged into the same CLI tree built by [`BuildCli`](crate::command::BuildCli).