From 9ebc450345ea4894f179ca6d383cb74071742086 Mon Sep 17 00:00:00 2001 From: Julius de Bruijn Date: Tue, 3 Mar 2020 18:00:24 +0100 Subject: [PATCH] Unify cli input parsing - Version command displays the binary name and commit id everywhere - All long cli params are now kebab-case instead of snake_case, the standard - The prisma-fmt has now subcommands `format` and `lint` instead of one boolean flag `lint` that when set lints and when not set formats. --- Cargo.lock | 3 +- README.md | 12 +- introspection-engine/core/Cargo.toml | 1 + introspection-engine/core/src/cli.rs | 12 -- introspection-engine/core/src/main.rs | 25 +-- libs/test-cli/build.rs | 7 + libs/test-cli/src/main.rs | 9 +- migration-engine/cli/README.md | 6 +- migration-engine/cli/src/commands.rs | 4 +- migration-engine/cli/src/commands/tests.rs | 20 +- migration-engine/cli/src/error_tests.rs | 6 +- migration-engine/cli/src/main.rs | 14 +- prisma-fmt/Cargo.toml | 4 +- prisma-fmt/src/format.rs | 36 ++++ prisma-fmt/src/lint.rs | 37 ++++ prisma-fmt/src/main.rs | 172 +++++------------- .../src/test/scala/util/TestDatabase.scala | 2 +- .../src/test/scala/util/TestServer.scala | 20 +- query-engine/prisma/src/main.rs | 7 +- 19 files changed, 184 insertions(+), 213 deletions(-) delete mode 100644 introspection-engine/core/src/cli.rs create mode 100644 libs/test-cli/build.rs create mode 100644 prisma-fmt/src/format.rs create mode 100644 prisma-fmt/src/lint.rs diff --git a/Cargo.lock b/Cargo.lock index 74364a7d57ae..96876295449d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -998,6 +998,7 @@ dependencies = [ "serde_derive", "serde_json", "sql-introspection-connector", + "structopt", "test-setup", "thiserror", "tokio", @@ -1983,10 +1984,10 @@ dependencies = [ name = "prisma-fmt" version = "0.1.0" dependencies = [ - "clap", "datamodel", "serde", "serde_json", + "structopt", ] [[package]] diff --git a/README.md b/README.md index 00fcdef7ed4d..dd2062c5b288 100644 --- a/README.md +++ b/README.md @@ -76,8 +76,8 @@ USAGE: prisma [FLAGS] [OPTIONS] [SUBCOMMAND] FLAGS: - --always_force_transactions Runs all queries in a transaction, including all the reads - --enable_raw_queries Enables raw SQL queries with executeRaw mutation + --always-force-transactions Runs all queries in a transaction, including all the reads + --enable-raw-queries Enables raw SQL queries with executeRaw mutation -h, --help Prints help information --legacy Switches query schema generation to Prisma 1 compatible mode -V, --version Prints version information @@ -101,10 +101,10 @@ FLAGS: -V, --version Prints version information SUBCOMMANDS: - --dmmf Output the DMMF from the loaded data model - --dmmf_to_dml Convert the given DMMF JSON file to a data model - --execute_request Executes one request and then terminates - --get_config Get the configuration from the given data model + dmmf Output the DMMF from the loaded data model + dmmf-to-dml Convert the given DMMF JSON file to a data model + execute-request Executes one request and then terminates + get-config Get the configuration from the given data model help Prints this message or the help of the given subcommand(s) ``` diff --git a/introspection-engine/core/Cargo.toml b/introspection-engine/core/Cargo.toml index e80f9a1d44bd..7f906e289242 100644 --- a/introspection-engine/core/Cargo.toml +++ b/introspection-engine/core/Cargo.toml @@ -12,6 +12,7 @@ introspection-connector = { path = "../connectors/introspection-connector" } sql-introspection-connector = { path = "../connectors/sql-introspection-connector" } clap = "2.33" +structopt = "0.3" serde = "1.0" anyhow = "1.0.26" thiserror = "1.0.9" diff --git a/introspection-engine/core/src/cli.rs b/introspection-engine/core/src/cli.rs deleted file mode 100644 index 1d39116897fc..000000000000 --- a/introspection-engine/core/src/cli.rs +++ /dev/null @@ -1,12 +0,0 @@ -use clap::{App, Arg}; -pub fn clap_app() -> clap::App<'static, 'static> { - App::new("Prisma Introspection Engine") - .version(env!("CARGO_PKG_VERSION")) - .arg( - Arg::with_name("version") - .long("version") - .help("Prints the server commit ID") - .takes_value(false) - .required(false), - ) -} diff --git a/introspection-engine/core/src/main.rs b/introspection-engine/core/src/main.rs index 6ebccaf720a5..8570a9b54b5e 100644 --- a/introspection-engine/core/src/main.rs +++ b/introspection-engine/core/src/main.rs @@ -1,26 +1,27 @@ -use jsonrpc_core::*; -use rpc::{Rpc, RpcImpl}; -pub mod cli; mod command_error; mod error; mod error_rendering; mod rpc; +use jsonrpc_core::*; +use rpc::{Rpc, RpcImpl}; +use structopt::StructOpt; + +#[derive(Debug, StructOpt, Clone)] +#[structopt(version = env!("GIT_HASH"))] +pub struct IntrospectionOpt {} + #[tokio::main] async fn main() { - let matches = cli::clap_app().get_matches(); init_logger(); - if matches.is_present("version") { - println!(env!("GIT_HASH")); - } else { - user_facing_errors::set_panic_hook(); + let _ = IntrospectionOpt::from_args(); + user_facing_errors::set_panic_hook(); - let mut io_handler = IoHandler::new(); - io_handler.extend_with(RpcImpl::new().to_delegate()); + let mut io_handler = IoHandler::new(); + io_handler.extend_with(RpcImpl::new().to_delegate()); - json_rpc_stdio::run(&io_handler).await.unwrap(); - } + json_rpc_stdio::run(&io_handler).await.unwrap(); } fn init_logger() { diff --git a/libs/test-cli/build.rs b/libs/test-cli/build.rs new file mode 100644 index 000000000000..a2512d3fc7ab --- /dev/null +++ b/libs/test-cli/build.rs @@ -0,0 +1,7 @@ +use std::process::Command; + +fn main() { + let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().unwrap(); + let git_hash = String::from_utf8(output.stdout).unwrap(); + println!("cargo:rustc-env=GIT_HASH={}", git_hash); +} diff --git a/libs/test-cli/src/main.rs b/libs/test-cli/src/main.rs index 7f1a872a9b03..e7f213694175 100644 --- a/libs/test-cli/src/main.rs +++ b/libs/test-cli/src/main.rs @@ -3,18 +3,18 @@ use colored::Colorize; use structopt::*; #[derive(StructOpt)] +#[structopt(version = env!("GIT_HASH"))] enum Command { /// Apply a prisma schema to a database - #[structopt(name = "apply-schema")] ApplySchema { /// The path to the prisma schema file. Either this or --stdin should be provided. - #[structopt(long = "file-path")] + #[structopt(long)] file_path: Option, /// Try to read the prisma schema from stdin. Either this or --file-path should be provided. - #[structopt(long = "stdin")] + #[structopt(long)] stdin: bool, /// Whether to ignore warnings from the migration engine regarding data loss. Default: false. - #[structopt(long = "force")] + #[structopt(long)] force: Option, }, } @@ -58,7 +58,6 @@ fn main() -> anyhow::Result<()> { }; let result = api.apply_migration(&apply_input).await?; - let warnings = result.warnings.into_iter().map(|warning| warning.description).collect(); Ok::, anyhow::Error>(warnings) diff --git a/migration-engine/cli/README.md b/migration-engine/cli/README.md index 792b5cc93b09..3cc12018d697 100644 --- a/migration-engine/cli/README.md +++ b/migration-engine/cli/README.md @@ -13,7 +13,7 @@ USAGE: FLAGS: -h, --help Prints help information - -s, --single_cmd Run only a single command, then exit + -s, --single-cmd Run only a single command, then exit --version Prints the server commit ID OPTIONS: @@ -41,7 +41,7 @@ OPTIONS: -d, --datasource The connection string to the database SUBCOMMANDS: - --can_connect_to_database Does the database connection string work? - --create_database Create an empty database defined in the configuration string + can-connect-to-database Does the database connection string work? + create-database Create an empty database defined in the configuration string help Prints this message or the help of the given subcommand(s) ``` diff --git a/migration-engine/cli/src/commands.rs b/migration-engine/cli/src/commands.rs index c1eb7abc09c8..9fe6820c63d5 100644 --- a/migration-engine/cli/src/commands.rs +++ b/migration-engine/cli/src/commands.rs @@ -16,7 +16,7 @@ use url::Url; #[derive(Debug, StructOpt)] pub(crate) struct Cli { /// The connection string to the database - #[structopt(long = "datasource", short = "d")] + #[structopt(long, short = "d")] datasource: String, #[structopt(subcommand)] command: CliCommand, @@ -63,10 +63,8 @@ impl Cli { #[derive(Debug, StructOpt)] enum CliCommand { /// Create an empty database defined in the configuration string. - #[structopt(name = "--create_database")] CreateDatabase, /// Does the database connection string work? - #[structopt(name = "--can_connect_to_database")] CanConnectToDatabase, } diff --git a/migration-engine/cli/src/commands/tests.rs b/migration-engine/cli/src/commands/tests.rs index c6d420731f61..141fd1ab2a6c 100644 --- a/migration-engine/cli/src/commands/tests.rs +++ b/migration-engine/cli/src/commands/tests.rs @@ -24,7 +24,7 @@ fn mysql_url(db: Option<&str>) -> String { #[tokio::test] async fn test_connecting_with_a_working_mysql_connection_string() { - let result = run(&["--datasource", &mysql_url(None), "--can_connect_to_database"]) + let result = run(&["--datasource", &mysql_url(None), "can-connect-to-database"]) .await .unwrap(); @@ -34,7 +34,7 @@ async fn test_connecting_with_a_working_mysql_connection_string() { #[tokio::test] async fn test_connecting_with_a_non_working_mysql_connection_string() { let datasource = mysql_url(Some("this_does_not_exist")); - let err = run(&["--datasource", &datasource, "--can_connect_to_database"]) + let err = run(&["--datasource", &datasource, "can-connect-to-database"]) .await .unwrap_err(); @@ -44,7 +44,7 @@ async fn test_connecting_with_a_non_working_mysql_connection_string() { #[tokio::test] async fn test_connecting_with_a_working_psql_connection_string() { let datasource = postgres_url(None); - let result = run(&["--datasource", &datasource, "--can_connect_to_database"]) + let result = run(&["--datasource", &datasource, "can-connect-to-database"]) .await .unwrap(); @@ -56,7 +56,7 @@ async fn test_connecting_with_a_working_psql_connection_string_with_postgres_sch let result = run(&[ "--datasource", &postgres_url_with_scheme(None, "postgres"), - "--can_connect_to_database", + "can-connect-to-database", ]) .await .unwrap(); @@ -67,7 +67,7 @@ async fn test_connecting_with_a_working_psql_connection_string_with_postgres_sch #[tokio::test] async fn test_connecting_with_a_non_working_psql_connection_string() { let datasource = postgres_url(Some("this_does_not_exist")); - let err = run(&["--datasource", &datasource, "--can_connect_to_database"]) + let err = run(&["--datasource", &datasource, "can-connect-to-database"]) .await .unwrap_err(); @@ -78,7 +78,7 @@ async fn test_connecting_with_a_non_working_psql_connection_string() { async fn test_create_mysql_database() { let url = mysql_url(Some("this_should_exist")); - let res = run(&["--datasource", &url, "--create_database"]).await; + let res = run(&["--datasource", &url, "create-database"]).await; assert_eq!( "Database 'this_should_exist' created successfully.", @@ -86,7 +86,7 @@ async fn test_create_mysql_database() { ); if let Ok(_) = res { - let res = run(&["--datasource", &url, "--can_connect_to_database"]).await; + let res = run(&["--datasource", &url, "can-connect-to-database"]).await; assert_eq!("Connection successful", res.as_ref().unwrap()); { @@ -120,14 +120,14 @@ async fn test_create_psql_database() { let url = postgres_url(Some(db_name)); - let res = run(&["--datasource", &url, "--create_database"]).await; + let res = run(&["--datasource", &url, "create-database"]).await; assert_eq!( "Database 'this_should_exist' created successfully.", res.as_ref().unwrap() ); - let res = run(&["--datasource", &url, "--can_connect_to_database"]).await; + let res = run(&["--datasource", &url, "can-connect-to-database"]).await; assert_eq!("Connection successful", res.as_ref().unwrap()); res.unwrap(); @@ -146,7 +146,7 @@ async fn test_create_sqlite_database() { let url = format!("file:{}", sqlite_path.to_string_lossy()); - let res = run(&["--datasource", &url, "--create_database"]).await; + let res = run(&["--datasource", &url, "create-database"]).await; assert_eq!("", res.as_ref().unwrap()); assert!(sqlite_path.exists()); diff --git a/migration-engine/cli/src/error_tests.rs b/migration-engine/cli/src/error_tests.rs index 280f41b7b444..242bab6cf744 100644 --- a/migration-engine/cli/src/error_tests.rs +++ b/migration-engine/cli/src/error_tests.rs @@ -16,7 +16,7 @@ async fn database_already_exists_must_return_a_proper_error() { .await .ok(); - let error = get_cli_error(&["migration-engine", "cli", "--datasource", &url, "--create_database"]).await; + let error = get_cli_error(&["migration-engine", "cli", "--datasource", &url, "create-database"]).await; let (host, port) = { let url = Url::parse(&url).unwrap(); @@ -60,7 +60,7 @@ async fn database_access_denied_must_return_a_proper_error_in_cli() { "cli", "--datasource", url.as_str(), - "--can_connect_to_database", + "can-connect-to-database", ]) .await; @@ -89,7 +89,7 @@ async fn tls_errors_must_be_mapped_in_the_cli() { "cli", "--datasource", &url, - "--can_connect_to_database", + "can-connect-to-database", ]) .await; diff --git a/migration-engine/cli/src/main.rs b/migration-engine/cli/src/main.rs index bfb3ad3c17fd..999fc06038c0 100644 --- a/migration-engine/cli/src/main.rs +++ b/migration-engine/cli/src/main.rs @@ -9,17 +9,14 @@ use structopt::StructOpt; /// When no subcommand is specified, the migration engine will default to starting as a JSON-RPC /// server over stdio. #[derive(Debug, StructOpt)] -#[structopt(no_version)] +#[structopt(version = env!("GIT_HASH"))] struct MigrationEngineCli { /// Run only a single command, then exit - #[structopt(short = "s", long = "single_cmd")] + #[structopt(short = "s", long)] single_cmd: bool, /// Path to the datamodel - #[structopt(short = "d", long = "datamodel", name = "FILE")] + #[structopt(short = "d", long, name = "FILE")] datamodel: Option, - /// Prints the server commit ID - #[structopt(long = "version")] - version: bool, #[structopt(subcommand)] cli_subcommand: Option, } @@ -47,11 +44,6 @@ async fn main() { let input = MigrationEngineCli::from_args(); - if input.version { - println!(env!("GIT_HASH")); - std::process::exit(0); - } - match input.cli_subcommand { None => { if let Some(datamodel_location) = input.datamodel.as_ref() { diff --git a/prisma-fmt/Cargo.toml b/prisma-fmt/Cargo.toml index cd4e71c3514e..51139694fca7 100644 --- a/prisma-fmt/Cargo.toml +++ b/prisma-fmt/Cargo.toml @@ -6,6 +6,6 @@ edition = "2018" [dependencies] datamodel = { path = "../libs/datamodel/core" } -clap = "2.33.0" +structopt = "0.3" serde = { version = "1.0.90", features = ["derive"] } -serde_json = "1.0" \ No newline at end of file +serde_json = "1.0" diff --git a/prisma-fmt/src/format.rs b/prisma-fmt/src/format.rs new file mode 100644 index 000000000000..2103f28e2ec8 --- /dev/null +++ b/prisma-fmt/src/format.rs @@ -0,0 +1,36 @@ +use datamodel::ast::reformat::Reformatter; +use std::{ + fs::{self, File}, + io::{self, BufWriter, Read}, +}; + +use crate::FormatOpts; + +pub fn run(opts: FormatOpts) { + let datamodel_string = match opts.input { + Some(file_name) => { + fs::read_to_string(&file_name).expect(&format!("Unable to open file {}", file_name.display())) + } + None => { + let mut buf = String::new(); + + io::stdin() + .read_to_string(&mut buf) + .expect("Unable to read from stdin."); + + buf + } + }; + + match opts.output { + Some(file_name) => { + let file = File::open(&file_name).expect(&format!("Unable to open file {}", file_name.display())); + let mut stream = BufWriter::new(file); + + Reformatter::reformat_to(&datamodel_string, &mut stream, opts.tabwidth); + } + None => { + Reformatter::reformat_to(&datamodel_string, &mut io::stdout().lock(), opts.tabwidth); + } + } +} diff --git a/prisma-fmt/src/lint.rs b/prisma-fmt/src/lint.rs new file mode 100644 index 000000000000..da8d287a2626 --- /dev/null +++ b/prisma-fmt/src/lint.rs @@ -0,0 +1,37 @@ +use crate::{LintOpts, MiniError}; +use datamodel::error::DatamodelError; +use serde_json; +use std::io::{self, Read}; + +pub fn run(opts: LintOpts) { + let mut datamodel_string = String::new(); + + io::stdin() + .read_to_string(&mut datamodel_string) + .expect("Unable to read from stdin."); + + let datamodel_result = if opts.no_env_errors { + datamodel::parse_datamodel_and_ignore_env_errors(&datamodel_string) + } else { + datamodel::parse_datamodel(&datamodel_string) + }; + + match datamodel_result { + Err(err) => { + let mini_errors: Vec = err + .errors + .iter() + .map(|err: &DatamodelError| MiniError { + start: err.span().start, + end: err.span().end, + text: format!("{}", err), + }) + .collect(); + + let json = serde_json::to_string(&mini_errors).expect("Failed to render JSON"); + + print!("{}", json) + } + _ => print!("[]"), + } +} diff --git a/prisma-fmt/src/main.rs b/prisma-fmt/src/main.rs index 778f9651b9bd..c21aff47ad5e 100644 --- a/prisma-fmt/src/main.rs +++ b/prisma-fmt/src/main.rs @@ -1,139 +1,53 @@ -use datamodel; -use datamodel::error::DatamodelError; -use std::{ - fs, - io::{self, Read}, -}; +mod format; +mod lint; + +use std::path::PathBuf; -use clap::{App, Arg}; use serde; -use serde_json; +use structopt::StructOpt; -#[derive(serde::Serialize)] -struct MiniError { - start: usize, - end: usize, - text: String, +#[derive(Debug, StructOpt, Clone)] +pub struct LintOpts { + /// If set, silences all `environment variable not found` errors + #[structopt(long)] + no_env_errors: bool, } -fn main() { - let matches = App::new("Prisma Datamodel v2 formatter") - .version("0.2") - .author("Emanuel Jöbstl ") - .about("Formats or lints a datamodel v2 file and prints the result to standard output.") - .arg( - Arg::with_name("input") - .short("i") - .long("input") - .value_name("INPUT_FILE") - .required(false) - .help("Specifies the input file to use. If none is given, the input is read from stdin."), - ) - .arg( - Arg::with_name("lint") - .short("l") - .long("lint") - .required(false) - .help("Specifies linter mode."), - ) - .arg( - Arg::with_name("no_env_errors") - .long("no_env_errors") - .required(false) - .help("If set, silences all `environment variable not found` errors."), - ) - .arg( - Arg::with_name("output") - .short("o") - .long("output") - .value_name("OUTPUT_FILE") - .required(false) - .help("Specifies the output file to use. If none is given, the output is written to stdout."), - ) - .arg( - Arg::with_name("tabwidth") - .short("s") - .long("tabwidth") - .value_name("WIDTH") - .required(false) - .help("Specifies wich tab width to use when formaitting. Default is 2."), - ) - .arg( - Arg::with_name("version") - .long("version") - .help("Prints the version") - .takes_value(false) - .required(false), - ) - .get_matches(); - - if matches.is_present("version") { - println!(env!("GIT_HASH")); - } else if matches.is_present("lint") { - // Linter - let skip_env_errors = matches.is_present("no_env_errors"); - let mut datamodel_string = String::new(); - io::stdin() - .read_to_string(&mut datamodel_string) - .expect("Unable to read from stdin."); - - let datamodel_result = if skip_env_errors { - datamodel::parse_datamodel_and_ignore_env_errors(&datamodel_string) - } else { - datamodel::parse_datamodel(&datamodel_string) - }; - - match datamodel_result { - Err(err) => { - let as_mini_errors: Vec = err - .errors - .iter() - .map(|err: &DatamodelError| MiniError { - start: err.span().start, - end: err.span().end, - text: format!("{}", err), - }) - .collect(); - let json = serde_json::to_string(&as_mini_errors).expect("Failed to render JSON"); - print!("{}", json) - } - _ => print!("[]"), - } - - std::process::exit(0); - } else { - // Formatter - let file_name = matches.value_of("input"); - let tab_width = matches - .value_of("tabwidth") - .unwrap_or("2") - .parse::() - .expect("Error while parsing tab width."); +#[derive(Debug, StructOpt, Clone)] +pub struct FormatOpts { + /// Specifies the input file to use. If none is given, the input is read + /// from STDIN + #[structopt(short = "i", long)] + input: Option, + /// Specifies the output file to use. If none is given, the output is + /// written to STDOUT + #[structopt(short = "o", long)] + output: Option, + /// Specifies wich tab width to use when formatting + #[structopt(short = "s", long, default_value = "2")] + tabwidth: usize, +} - // TODO: This is really ugly, clean it up. - let datamodel_string: String = if let Some(file_name) = file_name { - fs::read_to_string(&file_name).expect(&format!("Unable to open file {}", file_name)) - } else { - let mut buf = String::new(); - io::stdin() - .read_to_string(&mut buf) - .expect("Unable to read from stdin."); - buf - }; +#[derive(Debug, StructOpt, Clone)] +#[structopt(version = env!("GIT_HASH"))] +/// Prisma Datamodel v2 formatter +pub enum FmtOpts { + /// Specifies linter mode + Lint(LintOpts), + /// Specifies format mode + Format(FormatOpts), +} - let file_name = matches.value_of("output"); +#[derive(serde::Serialize)] +pub struct MiniError { + pub start: usize, + pub end: usize, + pub text: String, +} - if let Some(file_name) = file_name { - let file = std::fs::File::open(file_name).expect(&format!("Unable to open file {}", file_name)); - let mut stream = std::io::BufWriter::new(file); - datamodel::ast::reformat::Reformatter::reformat_to(&datamodel_string, &mut stream, tab_width); - } else { - datamodel::ast::reformat::Reformatter::reformat_to( - &datamodel_string, - &mut std::io::stdout().lock(), - tab_width, - ); - } - std::process::exit(0); +fn main() { + match FmtOpts::from_args() { + FmtOpts::Lint(opts) => lint::run(opts), + FmtOpts::Format(opts) => format::run(opts), } } diff --git a/query-engine/connector-test-kit/src/test/scala/util/TestDatabase.scala b/query-engine/connector-test-kit/src/test/scala/util/TestDatabase.scala index 62374c993b0b..1e07269c1990 100644 --- a/query-engine/connector-test-kit/src/test/scala/util/TestDatabase.scala +++ b/query-engine/connector-test-kit/src/test/scala/util/TestDatabase.scala @@ -54,7 +54,7 @@ case class MigrationEngine(project: Project) { def createDatabase(): Unit = { import scala.sys.process._ - val cmd = List(EnvVars.migrationEngineBinaryPath, "cli", "-d", project.dataSourceUrl, "--create_database") + val cmd = List(EnvVars.migrationEngineBinaryPath, "cli", "-d", project.dataSourceUrl, "create-database") cmd.! } diff --git a/query-engine/connector-test-kit/src/test/scala/util/TestServer.scala b/query-engine/connector-test-kit/src/test/scala/util/TestServer.scala index bf2a0f7cb463..911aa98567fc 100644 --- a/query-engine/connector-test-kit/src/test/scala/util/TestServer.scala +++ b/query-engine/connector-test-kit/src/test/scala/util/TestServer.scala @@ -80,10 +80,10 @@ case class TestServer() extends PlayJsonExtensions with LogSupport { Process( Seq( EnvVars.prismaBinaryPath, - "--enable_raw_queries", - "--always_force_transactions", + "--enable-raw-queries", + "--always-force-transactions", "cli", - "--execute_request", + "execute-request", "--legacy", encoded_query ), @@ -96,10 +96,10 @@ case class TestServer() extends PlayJsonExtensions with LogSupport { Process( Seq( EnvVars.prismaBinaryPath, - "--enable_raw_queries", - "--always_force_transactions", + "--enable-raw-queries", + "--always-force-transactions", "cli", - "--execute_request", + "execute-request", encoded_query ), None, @@ -111,9 +111,9 @@ case class TestServer() extends PlayJsonExtensions with LogSupport { Process( Seq( EnvVars.prismaBinaryPath, - "--enable_raw_queries", + "--enable-raw-queries", "cli", - "--execute_request", + "execute-request", "--legacy", encoded_query ), @@ -126,9 +126,9 @@ case class TestServer() extends PlayJsonExtensions with LogSupport { Process( Seq( EnvVars.prismaBinaryPath, - "--enable_raw_queries", + "--enable-raw-queries", "cli", - "--execute_request", + "execute-request", encoded_query ), None, diff --git a/query-engine/prisma/src/main.rs b/query-engine/prisma/src/main.rs index b12eeff61af3..f9130037a627 100644 --- a/query-engine/prisma/src/main.rs +++ b/query-engine/prisma/src/main.rs @@ -72,13 +72,10 @@ pub struct ExecuteRequestInput { #[derive(Debug, StructOpt, Clone)] pub enum CliOpt { /// Output the DMMF from the loaded data model. - #[structopt(name = "--dmmf")] Dmmf, /// Get the configuration from the given data model. - #[structopt(name = "--get_config")] GetConfig(GetConfigInput), /// Executes one request and then terminates. - #[structopt(name = "--execute_request")] ExecuteRequest(ExecuteRequestInput), } @@ -95,10 +92,10 @@ pub struct PrismaOpt { #[structopt(long)] legacy: bool, /// Runs all queries in a transaction, including all the reads. - #[structopt(long = "always_force_transactions")] + #[structopt(long)] always_force_transactions: bool, /// Enables raw SQL queries with executeRaw mutation - #[structopt(long = "enable_raw_queries")] + #[structopt(long)] enable_raw_queries: bool, #[structopt(subcommand)] subcommand: Option,