Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6717057
Failing test to catch and reproduce #143
pesse Jun 4, 2019
038981f
Merge branch 'develop' into feature/new_cli_library
pesse Jun 7, 2019
b21f651
Unit-Test to simulate passing all parameters that should be known
pesse Jun 7, 2019
ce849fc
Initial implementation of Picocli usage
pesse Jun 11, 2019
5520562
Some more tests around FileMapping
pesse Jun 12, 2019
f9c4cf7
New RunAction which does the logic based on RunCommandConfig
pesse Jun 12, 2019
d8cbce2
RunAction tested and functional so far
pesse Jun 12, 2019
3b5e168
Include RunAction into RunCommand
pesse Jun 12, 2019
60997d7
New entry point for Picocli
pesse Jun 12, 2019
d13ae5b
Extract functionality to interface
pesse Jun 12, 2019
5e86b01
Adapt tests to IRunCommand and implement necessary functionality
pesse Jun 12, 2019
00f3f5f
Change VersionCommand to Picocli
pesse Jun 12, 2019
2ce4e91
Change ReportersCommand to Picocli
pesse Jun 13, 2019
b88d5c5
Fix arity for mapping options and prevent NPE
pesse Jun 13, 2019
c80dc8c
Refactor RunCommandTest to cover new approach
pesse Jun 13, 2019
8eec2cb
Implement rules for printToScreen Reporters: Only one can go to screen
pesse Jun 13, 2019
ded39d3
Implemented new Picocli help
pesse Jun 13, 2019
6922e52
Removed some now unnecessary stuff
pesse Jun 13, 2019
5aa4c1d
We don't need the old RunCommand anymore, time to get rid of it
pesse Jun 13, 2019
60fcfaf
Improve help and help-tests
pesse Jun 13, 2019
a3608b5
Refactor: Remove unnecessary logic
pesse Jun 13, 2019
09bf357
Refactor: extract ReporterConfig -> ReporterOption conversion
pesse Jun 13, 2019
1b65b51
Refactor: getCommand() no longer needed
pesse Jun 13, 2019
77fd752
Refactor: Include only left check-functionality
pesse Jun 13, 2019
e443e3c
Refactor: Cleanup ReporterManager a bit
pesse Jun 13, 2019
0bdca7d
Get rid of JCommander dependency
pesse Jun 13, 2019
ae0e9c4
Move ConnectionString description to main Utplsql-Command
pesse Jun 18, 2019
f47c0de
Fix Typo
pesse Jun 18, 2019
bb18ea1
Some Refactorings and make things final
pesse Jun 18, 2019
1a984ff
Merge branch 'develop' into feature/new_cli_library
pesse Jun 18, 2019
81e0953
Reformatting
pesse Jun 18, 2019
a8acbb9
Add `-h` option to all commands and cover it with tests
pesse Jun 18, 2019
10bef7b
Adjust documentation to reflect parameter changes
pesse Jun 18, 2019
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
Prev Previous commit
Next Next commit
Implemented new Picocli help
  • Loading branch information
pesse committed Jun 13, 2019
commit ded39d3e7e9b3847a7fd285a32ef8e698bcb704f
24 changes: 21 additions & 3 deletions src/main/java/org/utplsql/cli/Cli.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Cli {

public static void main(String[] args) {

int exitCode = runWithExitCode(args);
int exitCode = runPicocliWithExitCode(args);

System.exit(exitCode);
}
Expand Down Expand Up @@ -67,15 +67,33 @@ static int runPicocliWithExitCode( String[] args ) {

List<CommandLine> parsedLines = commandLine.parse(args);

boolean commandWasRun = false;
for ( CommandLine parsedLine : parsedLines ) {
if (parsedLine.isUsageHelpRequested()) {
parsedLine.usage(System.out);
return 0;
}
else if (parsedLine.isVersionHelpRequested()) {
parsedLine.printVersionHelp(System.out);
return 0;
}

Object command = parsedLine.getCommand();
if ( command instanceof ICommand ) {
exitCode = ((ICommand)command).run();
commandWasRun = true;
break;
}
}
} catch (ParameterException e) {
e.printStackTrace();

if ( !commandWasRun ) {
commandLine.usage(System.out);
}
} catch (CommandLine.ParameterException e) {
System.err.println(e.getMessage());
if (!CommandLine.UnmatchedArgumentException.printSuggestions(e, System.err)) {
e.getCommandLine().usage(System.err);
}
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/utplsql/cli/RunPicocliCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ FileMapperConfig toFileMapperConfig() {
}
}

@Option(names = "-h", usageHelp = true, description = "display this help and exit")
boolean help;

private RunAction runAction;

private String[] splitOrEmpty(String value) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/utplsql/cli/UtplsqlPicocliCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
})
public class UtplsqlPicocliCommand {

@CommandLine.Option(names = "-h", usageHelp = true, description = "display this help and exit")
boolean help;

}
11 changes: 11 additions & 0 deletions src/test/java/org/utplsql/cli/HelpCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ void callHelp() {
assertTrue(output.contains("Usage:"));
}

@Test
void callRunHelp() {

capturer.start();
int result = TestHelper.runApp("run", "-h");
String output = capturer.stop();

assertEquals(0, result);
assertTrue(output.contains("Usage:"));
}

@Test
void callWithNoArgs() {

Expand Down