Skip to content

Commit

Permalink
add subset of shellcheck flags
Browse files Browse the repository at this point in the history
  • Loading branch information
blmaier committed Mar 7, 2024
1 parent 5807a4d commit b6f2f1a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::walk_scripts::WalkShellScript;
#[derive(Parser, Debug)]
struct Args {
/// Path to Shellcheck binary
#[arg(short='s', long, default_value = "shellcheck")]
#[arg(long, default_value = "shellcheck")]
shellcheck: PathBuf,

#[command(flatten)]
Expand Down
28 changes: 28 additions & 0 deletions src/shellcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,25 @@ pub struct Shellcheck {

#[derive(Parser, Clone, Debug)]
pub struct ShellcheckArgs {
/// Include warnings from sourced files (Shellcheck)
#[arg(short='a', long="check-sourced")]
check_sourced: bool,

/// Output format (Shellcheck)
#[arg(short='f', long, default_value_t = ShellcheckFormat::Json1)]
format: ShellcheckFormat,

/// Don't look for .shellcheckrc files (Shellcheck)
#[arg(long)]
norc: bool,

/// Specify dialect (Shellcheck)
#[arg(short='s', long)]
shell: Option<String>,

/// Allow 'source' outside of FILES (Shellcheck)
#[arg(short='x', long="external-sources")]
external_sources: bool,
}

impl Shellcheck {
Expand All @@ -51,7 +67,19 @@ impl Shellcheck {
T: IntoIterator<Item = OsString>,
{
let mut command = self.create_command();
if self.args.check_sourced {
command.arg("--check-sourced");
}
command.arg("--format").arg(self.args.format.to_string());
if self.args.norc {
command.arg("--norc");
}
if let Some(shell) = &self.args.shell {
command.arg("--shell").arg(shell);
}
if self.args.external_sources {
command.arg("--external-sources");
}
command.arg("--").args(files);
command
}
Expand Down

0 comments on commit b6f2f1a

Please sign in to comment.