Created
April 17, 2016 11:19
-
-
Save nikkatsa/f9e2c9f5f39f20d1a30d272f37d4d368 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
final CommandLine cmd = new DefaultParser().parse(PersonalInfoReader.createCommandLineOptions(), args); | |
if (cmd.hasOption(HELP_CMD_OPTION)) { | |
new HelpFormatter().printHelp(120, "java", "Person Parsing", PersonalInfoReader.createCommandLineOptions(), ""); | |
return; | |
} | |
final String name = cmd.getOptionValue(NAME_CMD_OPTION); | |
final String surname = cmd.getOptionValue(SURNAME_CMD_OPTION); | |
final int age = Integer.parseInt(cmd.getOptionValue(AGE_CMD_OPTION)); | |
final String email = cmd.hasOption(EMAIL_CMD_OPTION) ? cmd.getOptionValue(EMAIL_CMD_OPTION) : "<unknown>"; | |
log.info("%nName: %s%nSurname: %s%nAge:%d%nEmail:%s%n", name, surname, age, email); | |
} catch (final ParseException e) { | |
log.error(e.getMessage(), e); | |
throw new RuntimeException(e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment