Skip to main content

docspec_http/
cli.rs

1//! Command-line interface arguments for the `docspec-http` server binary.
2
3use clap::Parser;
4
5/// `DocSpec` HTTP API server — converts markdown to `BlockNote` JSON.
6#[must_use]
7#[non_exhaustive]
8#[derive(Parser, Debug, Clone)]
9#[command(version, about = "DocSpec HTTP API server (markdown → BlockNote JSON)")]
10pub struct Args {
11    /// Address to bind the server to.
12    #[arg(long, default_value = "127.0.0.1")]
13    pub host: String,
14
15    /// Port to listen on. Use 0 for OS-assigned.
16    #[arg(long, default_value_t = 3000)]
17    pub port: u16,
18}
19
20impl Args {
21    /// Convert CLI arguments into a [`crate::server::ServerConfig`].
22    #[inline]
23    #[must_use]
24    pub fn into_config(self) -> crate::server::ServerConfig {
25        crate::server::ServerConfig::new(self.host, self.port)
26    }
27
28    /// Create a new [`Args`] with the given host and port.
29    #[inline]
30    pub fn new(host: String, port: u16) -> Self {
31        Self { host, port }
32    }
33}