weldscli_lib/commands/
mod.rs

1use clap::{Parser, Subcommand};
2use std::path::PathBuf;
3
4#[derive(Parser)] // requires `derive` feature
5#[command(name = "welds")]
6#[command(about = "A post-modern ORM", long_about = None)]
7pub struct Args {
8    /// Set the path to the schema definition file (defaults to the current directory)
9    #[arg(short, long, value_name = "schema")]
10    pub schema_file: Option<PathBuf>,
11    /// Set the path to where the generated models will be saved (defaults to the path of the schema file)
12    #[arg(short, long, value_name = "project")]
13    pub project_dir: Option<PathBuf>,
14
15    /// Set the DATABASE_URL which will be used in the connection
16    #[arg(short, long, value_name = "database_url")]
17    pub database_url: Option<String>,
18
19    #[command(subcommand)]
20    pub command: Commands,
21
22    /// Force hiding of type that are not support by the enabled Database drivers
23    /// NOTE: you will need to resolve compile errors for unsupported types.
24    #[arg(long, value_name = "hide_unknown_types")]
25    pub hide_unknown_types: bool,
26}
27
28#[derive(Debug, Subcommand)]
29pub enum Commands {
30    /// Update the knowledge of database structures
31    Update { table: Option<String> },
32    /// Generate new models in your code based on the knowledge of the database
33    Generate { table: Option<String> },
34    /// Verify Welds can connect to the database in DATABASE_URL
35    TestConnection,
36}