Skip to content

Commit

Permalink
feat: add a validate subcommand to wdl bin
Browse files Browse the repository at this point in the history
  • Loading branch information
a-frantz committed Jan 7, 2025
1 parent 2bc6e06 commit ab49cc7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions wdl/src/bin/wdl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use wdl::ast::Validator;
use wdl::lint::LintVisitor;
use wdl::util::analyze;
use wdl::util::run;
use wdl::util::validate_inputs;
use wdl_ast::Node;
use wdl_ast::Severity;
use wdl_doc::document_workspace;
Expand Down Expand Up @@ -326,6 +327,26 @@ impl DocCommand {
}
}

/// Validates an input JSON file against a WDL task or workflow.
#[derive(Args)]
#[clap(disable_version_flag = true)]
pub struct ValidateCommand {
/// The path or URL to the source WDL file.
#[clap(value_name = "PATH or URL")]
pub document: String,

/// The path to the inputs file.
#[clap(value_name = "INPUTS")]
pub inputs: PathBuf,
}

impl ValidateCommand {
/// Executes the `validate` subcommand.
async fn exec(self) -> Result<()> {
validate_inputs(self.document, self.inputs).await
}
}

/// Runs a WDL workflow or task using local execution.
#[derive(Args)]
#[clap(disable_version_flag = true)]
Expand Down Expand Up @@ -419,6 +440,9 @@ enum Command {
/// Documents a workspace.
Doc(DocCommand),

/// Validates an input file.
Validate(ValidateCommand),

/// Runs a workflow or task.
Run(RunCommand),
}
Expand All @@ -441,6 +465,7 @@ async fn main() -> Result<()> {
Command::Analyze(cmd) => cmd.exec().await,
Command::Format(cmd) => cmd.exec().await,
Command::Doc(cmd) => cmd.exec().await,
Command::Validate(cmd) => cmd.exec().await,
Command::Run(cmd) => cmd.exec().await,
} {
eprintln!(
Expand Down

0 comments on commit ab49cc7

Please sign in to comment.