diff --git a/pgteal_cli/src/app.rs b/pgteal_cli/src/app.rs index 03b2a4f..1dadb37 100644 --- a/pgteal_cli/src/app.rs +++ b/pgteal_cli/src/app.rs @@ -9,7 +9,7 @@ pub fn get_app() -> Params { let matches = App::new("PG Teal") .version("0.0") .author("Lenscas ") - .about("Generates teal types and functions based on sql.") + .about("Generates teal types and functions based on sql files.") .arg( Arg::with_name("connection_string") .short("c") diff --git a/pgteal_cli/src/tl_generator.rs b/pgteal_cli/src/tl_generator.rs index 930d022..a92aaf4 100644 --- a/pgteal_cli/src/tl_generator.rs +++ b/pgteal_cli/src/tl_generator.rs @@ -129,22 +129,25 @@ fn make_function( let params: String = query .params .iter() - .map(|v| " \"".to_owned() + v + "\"") + .map(|v| " \"".to_owned() + v + "\"") .collect::>() .join(",\n"); - let params = format!("local param_order:{{string}} = {{\n{}\n}}", params); + let params = format!( + "local param_order:{{string}} = {{\n{}\n }}", + params + ); format!( - " {} - {} - local query_params = {{}} - for k,v in ipairs(param_order) do - query_params[k] = (params as {{string:{}}})[v] - end - return connection:{}( - [[{}]], - query_params - ) as {} - end", + "{} + {} + local query_params = {{}} + for k,v in ipairs(param_order) do + query_params[k] = (params as {{string:{}}})[v] + end + return connection:{}( +[[{}\n]], + query_params + ) as {} + end", function_header, params, shared::Input::get_type_name(tealr::Direction::ToLua), @@ -221,11 +224,11 @@ pub(crate) fn write_to_file( part.output_type.name, part.output_type.name ); - let functions = part.functions.join(",\n "); - reexported + &functions + "}" + let functions = part.functions.join(",\n"); + reexported + &functions + "\n }" }) .collect::>() - .join(","); + .join(",\n"); let path = get_path(teal_pattern, original_file_path); let path = Path::new(&path); @@ -233,7 +236,7 @@ pub(crate) fn write_to_file( std::fs::create_dir_all(path.parent().unwrap())?; let to_write = format!( - "local libpgteal = require(\"libpgteal\")\nlocal Connection = libpgteal.Connection\n{}\nreturn {{{}}}", + "local libpgteal = require(\"libpgteal\")\nlocal Connection = libpgteal.Connection\n{}\nreturn {{\n{}\n}}", glued_types, modules ); std::fs::write(path, to_write)?;