Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions crates/squawk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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!();
}
Expand Down
49 changes: 30 additions & 19 deletions docs/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <config-path>
-c, --config <config-path>
Path to the squawk config file (.squawk.toml)

--debug <format>
Output debug format [possible values: Lex, Parsed]

-e, --exclude <rule>...
--debug <format>
Output debug format [possible values: Lex, Parse, Ast]

--exclude-path <excluded-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 <rule>...
Exclude specific warnings

For example: --exclude=require-concurrent-index-creation,ban-drop-database

--pg-version <pg-version>
--pg-version <pg-version>
Specify postgres version

For example: --pg-version=13.0
--reporter <reporter>
Style of error reporting [possible values: Tty, Gcc, Json]
--reporter <reporter>
Style of error reporting [possible values: Tty, Gcc, Json, Gitlab]

--stdin-filepath <filepath>
--stdin-filepath <filepath>
Path to use in reporting for stdin


ARGS:
<path>...
Paths to search
<path>...
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
```
Loading