diff --git a/src/main/java/org/ballerinalang/command/Main.java b/src/main/java/org/ballerinalang/command/Main.java index 1b039fe..fbc9e9e 100644 --- a/src/main/java/org/ballerinalang/command/Main.java +++ b/src/main/java/org/ballerinalang/command/Main.java @@ -115,9 +115,14 @@ private static Optional getInvokedCmd(String... args) { cmdParser.setCommandName("ballerina"); cmdParser.setPosixClusteredShortOptionsAllowed(false); + CommandLine.ParseResult parseResult = cmdParser.parseArgs(args); List parsedCommands = cmdParser.parse(args); + if (parseResult.hasSubcommand()) { + return Optional.of((BCommand) parseResult.subcommand().commandSpec().userObject()); + } + if (parsedCommands.size() < 1) { return Optional.of(defaultCmd); }