Skip to content

Commit

Permalink
fix: CLI commands may be terminated with semicolon+whitespace (MINOR) (
Browse files Browse the repository at this point in the history
  • Loading branch information
vcrfxia committed Jan 7, 2020
1 parent da57002 commit 096b78f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public OutputFormat getOutputFormat() {
}

private Optional<CliCmdExecutor> getCliCommand(final String line) {
final List<String> parts = splitByUnquotedWhitespace(StringUtils.stripEnd(line, ";"));
final List<String> parts = splitByUnquotedWhitespace(StringUtils.stripEnd(line.trim(), ";"));
if (parts.isEmpty()) {
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,20 @@ public void shouldSupportCmdBeingTerminatedWithSemiColon() {
verify(cliCommand).execute(eq(ImmutableList.of("Arg0")), any());
}

@Test
public void shouldSupportCmdBeingTerminatedWithSemiColonAndWhitespace() {
// Given:
when(lineSupplier.get())
.thenReturn(CLI_CMD_NAME + WHITE_SPACE + "Arg0; \n")
.thenReturn("not a CLI command;");

// When:
console.readLine();

// Then:
verify(cliCommand).execute(eq(ImmutableList.of("Arg0")), any());
}

@Test
public void shouldSupportCmdWithQuotedArgBeingTerminatedWithSemiColon() {
// Given:
Expand Down

0 comments on commit 096b78f

Please sign in to comment.