diff --git a/crates/squawk/src/main.rs b/crates/squawk/src/main.rs index cbe8a9ee..4e9e3940 100644 --- a/crates/squawk/src/main.rs +++ b/crates/squawk/src/main.rs @@ -147,6 +147,9 @@ struct Opt { global = true )] no_assume_in_transaction: bool, + /// Do not exit with an error when provided path patterns do not match any files + #[structopt(long = "no-error-on-unmatched-pattern", global = true)] + no_error_on_unmatched_pattern: bool, } #[allow(clippy::too_many_lines)] @@ -213,10 +216,17 @@ Please open an issue at https://github.com/sbdchd/squawk/issues/new with the log conf.assume_in_transaction.unwrap_or_default() }; + let no_error_on_unmatched_pattern = if opts.no_error_on_unmatched_pattern { + opts.no_error_on_unmatched_pattern + } else { + false + }; + info!("pg version: {pg_version:?}"); info!("excluded rules: {:?}", &excluded_rules); info!("excluded paths: {:?}", &excluded_paths); info!("assume in a transaction: {assume_in_transaction:?}"); + info!("no error on unmatched pattern: {no_error_on_unmatched_pattern:?}"); let mut clap_app = Opt::clap(); let is_stdin = !io::stdin().is_terminal(); @@ -251,7 +261,9 @@ Please open an issue at https://github.com/sbdchd/squawk/issues/new with the log "Failed to find files for provided patterns: {:?}", opts.path_patterns ); - process::exit(1); + if !no_error_on_unmatched_pattern { + process::exit(1); + } } if !found_paths.is_empty() || is_stdin { let stdout = io::stdout(); @@ -275,7 +287,7 @@ Please open an issue at https://github.com/sbdchd/squawk/issues/new with the log )?; return Ok(exit_code); } - } else { + } else if !no_error_on_unmatched_pattern { clap_app.print_long_help()?; println!(); } diff --git a/docs/docs/cli.md b/docs/docs/cli.md index 66846446..208e1af4 100644 --- a/docs/docs/cli.md +++ b/docs/docs/cli.md @@ -130,49 +130,60 @@ USAGE: squawk [FLAGS] [OPTIONS] [path]... [SUBCOMMAND] FLAGS: - --assume-in-transaction + --assume-in-transaction Assume that a transaction will wrap each SQL file when run by a migration tool - + Use --no-assume-in-transaction to override any config file that sets this - -h, --help + -h, --help Prints help information - -V, --version + --no-error-on-unmatched-pattern + Do not exit with an error when provided path patterns do not match any files + + -V, --version Prints version information - --verbose + --verbose Enable debug logging output OPTIONS: - -c, --config + -c, --config Path to the squawk config file (.squawk.toml) - --debug - Output debug format [possible values: Lex, Parsed] - - -e, --exclude ... + --debug + Output debug format [possible values: Lex, Parse, Ast] + + --exclude-path ... + Paths to exclude + + For example: + + `--exclude-path=005_user_ids.sql --exclude-path=009_account_emails.sql` + + `--exclude-path='*user_ids.sql'` + -e, --exclude ... Exclude specific warnings - + For example: --exclude=require-concurrent-index-creation,ban-drop-database - - --pg-version + --pg-version Specify postgres version - + For example: --pg-version=13.0 - --reporter - Style of error reporting [possible values: Tty, Gcc, Json] + --reporter + Style of error reporting [possible values: Tty, Gcc, Json, Gitlab] - --stdin-filepath + --stdin-filepath Path to use in reporting for stdin ARGS: - ... - Paths to search + ... + Paths or patterns to search SUBCOMMANDS: help Prints this message or the help of the given subcommand(s) + server Run the language server upload-to-github Comment on a PR with Squawk's results ```