2023-01-28 20:21:19 +01:00
|
|
|
use clap::{Arg, ArgMatches};
|
|
|
|
|
2023-01-29 12:58:57 +01:00
|
|
|
use crate::{config::Config, engine::Engine, session::Session};
|
2023-01-28 20:21:19 +01:00
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
pub struct GenerateCommand;
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
impl GenerateCommand {
|
|
|
|
pub fn new_cmd() -> clap::Command {
|
|
|
|
clap::Command::new("generate").arg(Arg::new("output").long("output"))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn exec(arg_matches: &ArgMatches) -> eyre::Result<()> {
|
|
|
|
let cfg = Config::default();
|
|
|
|
let (conn, _proc) = Engine::new().start(&cfg)?;
|
|
|
|
let session = Session::new();
|
|
|
|
let req = session.start(&cfg, &conn)?;
|
|
|
|
let schema = session.schema(req)?;
|
2023-01-29 12:58:57 +01:00
|
|
|
//let code = CodeGeneration::generate(&schema)?;
|
2023-01-28 20:21:19 +01:00
|
|
|
|
|
|
|
if let Some(output) = arg_matches.get_one::<String>("output") {
|
|
|
|
// TODO: Write to file
|
|
|
|
} else {
|
2023-01-29 12:58:57 +01:00
|
|
|
//println!("{}", code);
|
2023-01-28 20:21:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|