Skip to content
Open
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
7 changes: 5 additions & 2 deletions app/src/main/java/io/seqera/wave/cli/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ else if( result.isVersionHelpRequested() ) {

app.setLogLevel();
app.defaultArgs();
// validate the command line args
app.validateArgs();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it's needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inspect is running before this validation so either i can validate it in inspect method or move validate method before inspect method

if( app.info ) {
app.printInfo();
}
Expand Down Expand Up @@ -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) )
Expand Down Expand Up @@ -432,8 +437,6 @@ public void inspect() {

@Override
public void run() {
// validate the command line args
validateArgs();
// prepare the request
buildContext = prepareContext();
containerConfig = prepareConfig();
Expand Down
16 changes: 16 additions & 0 deletions app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}

}