nautilus_cli/
opt.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.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#[derive(Debug, Parser)]
19#[clap(version, about, author)]
20pub struct NautilusCli {
21    #[clap(subcommand)]
22    pub command: Commands,
23}
24
25#[derive(Parser, Debug)]
26pub enum Commands {
27    Database(DatabaseOpt),
28}
29
30#[derive(Parser, Debug)]
31#[command(about = "Postgres database operations", long_about = None)]
32pub struct DatabaseOpt {
33    #[clap(subcommand)]
34    pub command: DatabaseCommand,
35}
36
37#[derive(Parser, Debug, Clone)]
38pub struct DatabaseConfig {
39    /// Hostname or IP address of the database server.
40    #[arg(long)]
41    pub host: Option<String>,
42    /// Port number of the database server.
43    #[arg(long)]
44    pub port: Option<u16>,
45    /// Username for connecting to the database.
46    #[arg(long)]
47    pub username: Option<String>,
48    /// Name of the database.
49    #[arg(long)]
50    pub database: Option<String>,
51    /// Password for connecting to the database.
52    #[arg(long)]
53    pub password: Option<String>,
54    /// Directory path to the schema files.
55    #[arg(long)]
56    pub schema: Option<String>,
57}
58
59#[derive(Parser, Debug, Clone)]
60#[command(about = "Postgres database operations", long_about = None)]
61pub enum DatabaseCommand {
62    /// Initializes a new Postgres database with the latest schema.
63    Init(DatabaseConfig),
64    /// Drops roles, privileges and deletes all data from the database.
65    Drop(DatabaseConfig),
66}