trillium_cli/
lib.rs

1#![forbid(unsafe_code)]
2#![deny(
3    clippy::dbg_macro,
4    missing_debug_implementations,
5    nonstandard_style,
6    missing_copy_implementations,
7    unused_qualifications
8)]
9
10#[cfg(feature = "client")]
11pub(crate) mod client;
12#[cfg(any(feature = "proxy", feature = "client", feature = "serve"))]
13pub(crate) mod client_tls;
14#[cfg(all(unix, feature = "dev-server"))]
15pub(crate) mod dev_server;
16#[cfg(feature = "proxy")]
17pub(crate) mod proxy;
18#[cfg(feature = "serve")]
19pub(crate) mod serve;
20use clap::Parser;
21
22pub fn main() {
23    Cli::parse().run()
24}
25
26#[derive(Parser, Debug)]
27#[command(author, version, about)]
28pub enum Cli {
29    #[cfg(feature = "serve")]
30    /// Static file server and reverse proxy
31    Serve(serve::StaticCli),
32
33    #[cfg(all(unix, feature = "dev-server"))]
34    /// Development server for trillium applications
35    DevServer(dev_server::DevServer),
36
37    #[cfg(feature = "client")]
38    /// Make http requests using the trillium client
39    Client(client::ClientCli),
40
41    #[cfg(feature = "proxy")]
42    /// Run a http proxy
43    Proxy(proxy::ProxyCli),
44}
45
46impl Cli {
47    pub fn run(self) {
48        use Cli::*;
49        match self {
50            #[cfg(feature = "serve")]
51            Serve(s) => s.run(),
52            #[cfg(all(unix, feature = "dev-server"))]
53            DevServer(d) => d.run(),
54            #[cfg(feature = "client")]
55            Client(c) => c.run(),
56            #[cfg(feature = "proxy")]
57            Proxy(p) => p.run(),
58        }
59    }
60}
61
62#[cfg(any(feature = "proxy", feature = "serve"))]
63mod server_tls;