Skip to main content

topcoat_cli/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3mod asset;
4mod common;
5mod dev;
6mod fmt;
7mod ui;
8
9use clap::{Parser, Subcommand};
10
11#[derive(Parser)]
12#[command(name = "topcoat")]
13pub struct TopcoatCli {
14    #[command(subcommand)]
15    command: Command,
16}
17
18impl TopcoatCli {
19    pub async fn run(self) {
20        match self.command {
21            Command::Ui(cmd) => cmd.run(),
22            Command::Fmt(cmd) => cmd.run().await,
23            Command::Dev(cmd) => cmd.run().await,
24            Command::Asset(cmd) => cmd.run().await,
25        }
26    }
27}
28
29#[derive(Subcommand)]
30enum Command {
31    /// Start a development server
32    Dev(dev::DevCommand),
33    /// Format topcoat `view!` macros
34    Fmt(fmt::FmtCommand),
35    /// Inspect assets embedded in the binary
36    Asset(asset::AssetCommand),
37    /// Manage premade UI components in your project
38    Ui(ui::UiCommand),
39}
40
41pub async fn run() {
42    common::version::warn_on_mismatch();
43    TopcoatCli::parse().run().await;
44}