Skip to content

Commit

Permalink
Improve cli help formatting (fixes #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
alechenninger committed Nov 29, 2015
1 parent 54e6910 commit 057a028
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions bin/src/io/github/alechenninger/monarch/CliInputs.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,63 +13,65 @@
import java.util.Optional;

public class CliInputs implements Inputs {
// NOTE: Special unicode whitespace used in descriptions to defeat help format whitespace trim.
private final Option hierarchyOption = Option.builder("h")
.longOpt("hierarchy")
.hasArg()
.argName("path to hierarchy yaml")
.argName("path")
.desc("Path to a yaml file describing the source hierarchy, relative to the data directory "
+ "(see data-dir option). For example: \n"
+ "global.yaml:\n"
+ " teams/myteam.yaml:\n"
+ " teams/myteam/dev.yaml\n"
+ " teams/myteam/stage.yaml\n"
+ " teams/myteam/prod.yaml\n"
+ " teams/otherteam.yaml")
+ "  teams/myteam.yaml:\n"
+ "    teams/myteam/dev.yaml\n"
+ "    teams/myteam/stage.yaml\n"
+ "    teams/myteam/prod.yaml\n"
+ "  teams/otherteam.yaml")
.build();

private final Option changesOption = Option.builder("c")
.longOpt("changes")
.hasArg()
.argName("path to changes yaml")
.argName("path")
.desc("Path to a yaml file describing the desired end-state changes. For example: \n"
+ "---\n"
+ " source: teams/myteam.yaml\n"
+ " set:\n"
+ " myapp::version: 2\n"
+ " myapp::favorite_website: http://www.redhat.com\n"
+ "  source: teams/myteam.yaml\n"
+ "  set:\n"
+ "    myapp::version: 2\n"
+ "    myapp::favorite_website: http://www.redhat.com\n"
+ "---\n"
+ " source: teams/myteam/stage.yaml\n"
+ " set:\n"
+ " myapp::favorite_website: http://stage.redhat.com")
+ "  source: teams/myteam/stage.yaml\n"
+ "  set:\n"
+ "    myapp::favorite_website: http://stage.redhat.com")
.build();

private final Option pivotSourceOption = Option.builder("p")
.longOpt("pivot")
.hasArg()
.argName("name of source to pivot on")
.argName("source")
.desc("A pivot source is the source in the source tree from where you want to change, "
+ "including itself and any sources beneath it in the hierarchy. Redundant keys will be "
+ "removed in sources beneath the pivot (that is, sources which inherit its values).")
+ "removed in sources beneath the pivot (that is, sources which inherit its values). "
+ "Ex: 'teams/myteam.yaml'")
.build();

private final Option dataDirectoryOption = Option.builder("d")
.longOpt("data-dir")
.argName("path to data directory")
.argName("path")
.hasArg()
.desc("Path to where existing data sources life. The data for sources describe in the "
+ "hierarchy is looked using the paths in the hierarchy relative to this folder.")
.build();

private final Option configPathOption = Option.builder()
.longOpt("config")
.argName("path to config file")
.argName("path")
.hasArg()
.desc("Path to file which configures default values for command line options.")
.build();

private final Option outputDirOption = Option.builder("o")
.longOpt("output-dir")
.argName("path to output directory")
.argName("path")
.hasArg()
.desc("Path to directory where result data sources will be written. Data sources will be "
+ "written using relative paths from hierarchy.")
Expand Down Expand Up @@ -143,7 +145,7 @@ public String helpMessage() {
StringWriter result = new StringWriter();
PrintWriter printWriter = new PrintWriter(result);

helpFormatter.printHelp(printWriter, HelpFormatter.DEFAULT_WIDTH,
helpFormatter.printHelp(printWriter, 80,
"monarch --hierarchy hierarchy.yaml --changes changes.yaml --pivot teams/myteam.yaml "
+ "--data-dir ~/hieradata --output-dir ./", null, options, HelpFormatter.DEFAULT_LEFT_PAD,
HelpFormatter.DEFAULT_DESC_PAD, "https://github.com/alechenninger/monarch");
Expand Down

0 comments on commit 057a028

Please sign in to comment.