Skip to content

Commit

Permalink
Merge pull request #370 from Ishad-M-I-M/validate-args
Browse files Browse the repository at this point in the history
Validate command arguments
  • Loading branch information
keizer619 authored Oct 28, 2024
2 parents 41c27ee + 7ff6201 commit 8427ae6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/org/ballerinalang/command/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,14 @@ private static Optional<BCommand> getInvokedCmd(String... args) {
cmdParser.setCommandName("ballerina");
cmdParser.setPosixClusteredShortOptionsAllowed(false);

CommandLine.ParseResult parseResult = cmdParser.parseArgs(args);

List<CommandLine> parsedCommands = cmdParser.parse(args);

if (parseResult.hasSubcommand()) {
return Optional.of((BCommand) parseResult.subcommand().commandSpec().userObject());
}

if (parsedCommands.size() < 1) {
return Optional.of(defaultCmd);
}
Expand Down

0 comments on commit 8427ae6

Please sign in to comment.