pub struct Opt {
pub debug: bool,
pub ugly: bool,
pub dir: bool,
pub rust_case: bool,
pub rustfmt_config: Option<String>,
pub rustfmt_config_path: Option<String>,
pub no_functions: bool,
pub use_tuples: Tuples,
pub third_party: Vec<ThirdParty>,
pub conn: String,
pub output: Option<PathBuf>,
}Expand description
The program options for the code generation
Fields§
§debug: boolActivate debug mode
ugly: boolSkip running output through rustfmt
dir: boolProgram will treat output as a directory name rather than a file and generate a whole crate. If output is not provided code is printed as usual
rust_case: boolConvert names from the database to rust standard (i.e. table names in CamelCase, fields and functions in snake_case)
rustfmt_config: Option<String>string passed to rustfmt –config
rustfmt_config_path: Option<String>string passed to rustfmt –config-path
no_functions: boolOnly make mappings for tables and views
use_tuples: TuplesHow to use tuples (used by default for just overloads). Options: overloads (the default, use tuples to represent function overloading). all (Have all functions take a tuple for consitency). none (skip mapping overloaded procs at all). one_overload (avoid tuples by only mapping the oldest sql proc in the database).
third_party: Vec<ThirdParty>A comma seperated list of third party crates which contain types that will be mapped to and from sql types. Valid values are “bit_vec,chrono,eui48,geo_types,rust_decimal,serde_json,time,uuid”
conn: StringString to connect to database, see tokio_postgres::Config for details. If not provided environment variable DATABASE_URL is checked instead
output: Option<PathBuf>Output file, stdout if not present
Implementations§
Source§impl Opt
impl Opt
Sourcepub fn get_cargo_toml(&self) -> String
pub fn get_cargo_toml(&self) -> String
Produce the Cargo.toml file contents (the dependecies of the generated code)
Sourcepub fn get_call_string(&self) -> String
pub fn get_call_string(&self) -> String
Build a call string that could be used to get the same options
pub fn get_client(&self) -> MyClient
Trait Implementations§
Source§impl StructOpt for Opt
impl StructOpt for Opt
Source§fn from_clap(matches: &ArgMatches<'_>) -> Self
fn from_clap(matches: &ArgMatches<'_>) -> Self
clap::ArgMatches. It’s guaranteed to succeed
if matches originates from an App generated by StructOpt::clap called on
the same type, otherwise it must panic.Source§fn from_args() -> Selfwhere
Self: Sized,
fn from_args() -> Selfwhere
Self: Sized,
std::env::args_os).
Calls clap::Error::exit on failure, printing the error message and aborting the program.Source§fn from_args_safe() -> Result<Self, Error>where
Self: Sized,
fn from_args_safe() -> Result<Self, Error>where
Self: Sized,
std::env::args_os).
Unlike StructOpt::from_args, returns clap::Error on failure instead of aborting the program,
so calling .exit is up to you.Source§fn from_iter<I>(iter: I) -> Self
fn from_iter<I>(iter: I) -> Self
Vec of your making.
Print the error message and quit the program in case of failure. Read more