Source:
public static void main(final String[] args) { final CommandLineApplication application = CommandLineApplication.builder() .command("id label create") .usage("[OPTIONS] <TYPE> [NAME]...") .description("Create IDs for NAME(s), or names read from standard input of type TYPE.") .helpText("With no NAME, or when NAME is -, read standard input.") .build(); final CommandLineOptions cmdOptions = new CommandLineOptions(); try { final OptionSet options = cmdOptions.parseOptions(args); if (cmdOptions.shouldPrintHelp()) { application.printHelpAndExit(cmdOptions); } cmdOptions.configureLogger(); final CreateLabelComponent createLabelComponent = DaggerCreateLabelComponent.builder() .configModule(cmdOptions.configModule()) .build(); final List<?> nonOptionArguments = options.nonOptionArguments(); final LabelType type = type(nonOptionArguments); final ImmutableSet<String> names = ImmutableSet.copyOf( Arrays.copyOfRange(args, 1, args.length)); final Store store = createLabelComponent.store(); final CreateLabel createLabel = createLabelComponent.createLabel(); final List<ListenableFuture<LabelId>> assignments = Lists.newArrayListWithCapacity(names.size()); for (final String name : names) { assignments.add(createLabel.createLabel(name, type)); } Futures.allAsList(assignments).get(); store.close(); } catch (IllegalArgumentException | OptionException e) { application.printError(e.getMessage()); System.exit(42); } catch (InvalidConfigException | ConfigException e) { System.err.println(e.getMessage()); System.exit(42); } catch (Exception e) { LOG.error("Fatal error while creating id", e); System.exit(42); } }

Target:
public static void main(final String[] args) { final CommandLineApplication application = CommandLineApplication.builder() .command("label create") .usage("[OPTIONS] <TYPE> [NAME]...") .description("Create IDs for NAME(s), or names read from standard input of type TYPE.") .helpText("With no NAME, or when NAME is -, read standard input.") .build(); final CommandLineOptions cmdOptions = new CommandLineOptions(); try { final OptionSet options = cmdOptions.parseOptions(args); if (cmdOptions.shouldPrintHelp()) { application.printHelpAndExit(cmdOptions); } cmdOptions.configureLogger(); final CreateLabelComponent createLabelComponent = DaggerCreateLabelComponent.builder() .configModule(cmdOptions.configModule()) .build(); final List<?> nonOptionArguments = options.nonOptionArguments(); final LabelType type = type(nonOptionArguments); final ImmutableSet<String> names = ImmutableSet.copyOf( Arrays.copyOfRange(args, 1, args.length)); final Store store = createLabelComponent.store(); final CreateLabel createLabel = createLabelComponent.createLabel(); final List<ListenableFuture<LabelId>> assignments = Lists.newArrayListWithCapacity(names.size()); for (final String name : names) { assignments.add(createLabel.createLabel(name, type)); } Futures.allAsList(assignments).get(); store.close(); } catch (IllegalArgumentException | OptionException e) { application.printError(e.getMessage()); System.exit(42); } catch (InvalidConfigException | ConfigException e) { System.err.println(e.getMessage()); System.exit(42); } catch (Exception e) { LOG.error("Fatal error while creating id", e); System.exit(42); } }