62 lines
1.6 KiB
Rust
62 lines
1.6 KiB
Rust
//! # `efo`
|
||
//!
|
||
//! The **command‑line interface** for `epoch_forge`. It exposes a single
|
||
//! binary `efo` that supports the following sub‑commands:
|
||
//!
|
||
//! - `epoch` – switch / advance time
|
||
//! - `event` – add / remove events
|
||
//! - `org` – add / remove organisations
|
||
//! - `chr` – add / remove characters
|
||
//! - `town` – add / remove towns
|
||
//! - `link` – add / remove links (alliances, wars, roads, etc.)
|
||
//!
|
||
//! Each sub‑command is implemented in its own module under `commands/`.
|
||
//! The `main.rs` file simply parses arguments with `clap` and dispatches
|
||
//! to the appropriate handler. The handlers share a common `World`
|
||
//! instance that they load from / persist to disk.
|
||
//!
|
||
//! ## Usage
|
||
//! ```sh
|
||
//! efo epoch switch 5
|
||
//! ```
|
||
use clap::{Parser, Subcommand};
|
||
|
||
use crate::{commands::epoch::cli_epoch::EpochCmd, error::AppError};
|
||
|
||
mod commands;
|
||
mod error;
|
||
|
||
/// Root parser – the “efo” program
|
||
#[derive(Parser, Debug)]
|
||
#[command(name = "efo")]
|
||
#[command(about = "Epoch Forge – manage organisations over time")]
|
||
struct Cli {
|
||
#[command(subcommand)]
|
||
command: TopLevelCmd,
|
||
}
|
||
|
||
#[derive(Subcommand, Debug)]
|
||
enum TopLevelCmd {
|
||
/// Epoch‑related actions
|
||
|
||
#[command(subcommand)]
|
||
Epoch(EpochCmd),
|
||
// Event(commands::event::EventCmd),
|
||
// Org(commands::org::OrgCmd),
|
||
// Chr(commands::chr::ChrCmd),
|
||
// Town(commands::town::TownCmd),
|
||
// Link(commands::link::LinkCmd),
|
||
}
|
||
|
||
fn main() -> Result<(), AppError> {
|
||
let cli = Cli::parse();
|
||
|
||
match cli.command {
|
||
TopLevelCmd::Epoch(cmd) => {
|
||
commands::epoch::handle_cmd(cmd)?;
|
||
}
|
||
}
|
||
|
||
Ok(())
|
||
}
|