nautilus_cli/opt.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2025 Posei Systems Pty Ltd. All rights reserved.
3// https://poseitrader.io
4//
5// Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6// You may not use this file except in compliance with the License.
7// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16use clap::Parser;
17
18/// Main CLI structure for parsing command-line arguments and options.
19///
20/// This is the entry point for the PoseiTrader command-line interface,
21/// providing access to various system management and operational commands.
22#[derive(Debug, Parser)]
23#[clap(version, about, author)]
24pub struct PoseiCli {
25 #[clap(subcommand)]
26 pub command: Commands,
27}
28
29/// Available top-level commands for the PoseiTrader CLI.
30#[derive(Parser, Debug)]
31pub enum Commands {
32 Database(DatabaseOpt),
33}
34
35/// Database management options and subcommands.
36#[derive(Parser, Debug)]
37#[command(about = "Postgres database operations", long_about = None)]
38pub struct DatabaseOpt {
39 #[clap(subcommand)]
40 pub command: DatabaseCommand,
41}
42
43/// Configuration parameters for database connection and operations.
44#[derive(Parser, Debug, Clone)]
45pub struct DatabaseConfig {
46 /// Hostname or IP address of the database server.
47 #[arg(long)]
48 pub host: Option<String>,
49 /// Port number of the database server.
50 #[arg(long)]
51 pub port: Option<u16>,
52 /// Username for connecting to the database.
53 #[arg(long)]
54 pub username: Option<String>,
55 /// Name of the database.
56 #[arg(long)]
57 pub database: Option<String>,
58 /// Password for connecting to the database.
59 #[arg(long)]
60 pub password: Option<String>,
61 /// Directory path to the schema files.
62 #[arg(long)]
63 pub schema: Option<String>,
64}
65
66/// Available database management commands.
67#[derive(Parser, Debug, Clone)]
68#[command(about = "Postgres database operations", long_about = None)]
69pub enum DatabaseCommand {
70 /// Initializes a new Postgres database with the latest schema.
71 Init(DatabaseConfig),
72 /// Drops roles, privileges and deletes all data from the database.
73 Drop(DatabaseConfig),
74}