diff --git a/app/src/main/java/io/seqera/wave/cli/App.java b/app/src/main/java/io/seqera/wave/cli/App.java index 0ff7192..2f193c5 100644 --- a/app/src/main/java/io/seqera/wave/cli/App.java +++ b/app/src/main/java/io/seqera/wave/cli/App.java @@ -241,6 +241,8 @@ else if( result.isVersionHelpRequested() ) { app.setLogLevel(); app.defaultArgs(); + // validate the command line args + app.validateArgs(); if( app.info ) { app.printInfo(); } @@ -348,6 +350,9 @@ protected void validateArgs() { if( singularity && !freeze ) throw new IllegalCliArgumentException("Singularity build requires enabling freeze mode"); + if( inspect && isEmpty(image) ) + throw new IllegalCliArgumentException("Option --inspect requires the use of container image (--image)"); + if( !isEmpty(contextDir) ) { // check that a container file has been provided if( isEmpty(containerFile) ) @@ -432,8 +437,6 @@ public void inspect() { @Override public void run() { - // validate the command line args - validateArgs(); // prepare the request buildContext = prepareContext(); containerConfig = prepareConfig(); diff --git a/app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy b/app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy index 83e31d8..8786e59 100644 --- a/app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy +++ b/app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy @@ -585,4 +585,20 @@ class AppTest extends Specification { '2.0.0' | '2.1.0' | '2.0.0 (required: 2.1.0)' } + def 'should fail when inspecting without container image' () { + given: + def app = new App() + String[] args = ["--conda-package", "bwa", "--freeze", "--singularity", "--inspect"] + + when: + def cli = new CommandLine(app) + cli.parseArgs(args) + and: + app.validateArgs() + then: + def e = thrown(IllegalCliArgumentException) + and: + e.getMessage() == "Option --inspect requires the use of container image (--image)" + } + }