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
59
60
|
use std::path::PathBuf;
use clap::{Parser, Subcommand};
#[derive(Parser)]
pub(crate) struct CliArgs {
#[command(subcommand)]
pub(crate) command: Command,
}
#[derive(Subcommand)]
pub(crate) enum Command {
/// Serve the server.
Serve {
/// Which port to serve the server on.
///
/// Leave empty to let the OS choose a free one.
#[arg(short, long)]
port: Option<u16>,
/// File containing the secret key,
/// used to sign the JWT cookies handed out to clients (as hex).
///
/// Leave empty to generate a random one.
/// Note that every client will be signed out, when this value changes (because the
/// rocie-server will not be able to verify the signatures made with the previous key
/// anymore).
///
/// As there are some requirements that this key needs to fulfill, you can use the
/// `generate-key` sub-command to generate a compliant key.
/// E.g.
/// ```sh
/// rocie-server generate-key > ./key.hex
/// rocie-server serve --secret-key-file ./key.hex ..
/// ```
#[arg(short, long, verbatim_doc_comment)]
secret_key_file: Option<PathBuf>,
/// Print the used port as single u16 to stdout when started.
///
/// This can be used to determine the used port, when the `port` was left at `None`.
#[arg(long)]
print_port: bool,
/// Which host to serve the server on.
#[arg(short = 'b', long, default_value = "127.0.0.1")]
host: String,
/// Path to the database to use to store data.
#[arg(short, long, env = "ROCIE_DB_PATH")]
db_path: PathBuf,
},
/// Print the `OpenAPI` API documentation to stdout.
OpenApi,
/// Generate (and print to stdout) a compliant secret key for use in the `serve --secret-key`
/// argument.
GenerateKey,
}
|