CLIManager cliManager = new CLIManager(); mavenConfig = cliManager.parse( args.toArray( new String[0] ) ); List<?> unrecongized = mavenConfig.getArgList(); if ( !unrecongized.isEmpty() ) cliManager.displayHelp( System.out ); throw e; cliRequest.commandLine = cliManager.parse( cliRequest.args ); cliRequest.commandLine = cliMerge( cliManager.parse( cliRequest.args ), mavenConfig ); cliManager.displayHelp( System.out ); throw e; cliManager.displayHelp( System.out ); throw new ExitException( 0 );
CommandLine config = cliManager.parse(args.toArray(new String[args.size()])); List<?> unrecongized = config.getArgList(); if (!unrecongized.isEmpty()) { cliManager.displayHelp(output); throw e; args.addAll(0, Arrays.asList(cliRequest.getArgs())); cliRequest.setCommandLine(cliManager.parse(args.toArray(new String[args.size()]))); } catch (ParseException e) { System.err.println("Unable to parse command line options: " + e.getMessage()); cliManager.displayHelp(output); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); cliManager.displayHelp(ps); throw e; cliManager.displayHelp(output); cliManager.displayHelp(ps); throw new ExitException(0);
@Test public void testGetTarget() throws ParseException { final String[] args = {"-t", "/fake/dir"}; CommandLine cl = new CLIManager().parse(args); Path path = new ToolConfig(cl).getTarget(); assertEquals(2, path.getNameCount()); assertEquals("fake", path.getName(0).toString()); } }
/** * Display the command line help if the option is present, then exit */ private void displayHelp() { if ( getCli().hasOption( OPT_DISPLAY_HELP ) ) { CLIManager.displayHelp(); LOGGER.info( "" ); exit( RC_OK ); } }
/** * Perform initialization. * * @param args * The command-line arguments. * * @throws ParseException * If there is an error parsing the command-line. * @throws IOException * If there is an error while reading the project descriptor. * @throws MalformedURLException * If any of the the URLs denoting the local or remote repositories is malformed. */ public void initialize( String[] args ) throws ParseException, MalformedURLException, IOException { setCli( CLIManager.parse( args ) ); initializeSystemProperties(); initializeRootContext(); initializeMavenSession(); customizeLogging(); }
public CommandLine parse( String[] args ) throws ParseException { // We need to eat any quotes surrounding arguments... String[] cleanArgs = cleanArgs( args ); CommandLineParser parser = new GnuParser(); return parser.parse( options, cleanArgs ); }
CLIManager.displayInfo(); LOGGER.info( "" ); LOGGER.info( MavenUtils.getMessage( "displayInfo.info1" ) );
CommandLine config = cliManager.parse(args.toArray(new String[args.size()])); List<?> unrecongized = config.getArgList(); if (!unrecongized.isEmpty()) { cliManager.displayHelp(output); throw e; args.addAll(0, Arrays.asList(cliRequest.getArgs())); cliRequest.setCommandLine(cliManager.parse(args.toArray(new String[args.size()]))); } catch (ParseException e) { System.err.println("Unable to parse command line options: " + e.getMessage()); cliManager.displayHelp(output); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); cliManager.displayHelp(ps); throw e; cliManager.displayHelp(output); cliManager.displayHelp(ps); throw new ExitException(0);
CLIManager.displayHelp(); returnCode = RC_BAD_ARG;
private void cli( CliRequest cliRequest ) throws Exception { CLIManager cliManager = new CLIManager(); try { cliRequest.commandLine = cliManager.parse( cliRequest.args ); } catch ( ParseException e ) { cliRequest.stderr.println( "Unable to parse command line options: " + e.getMessage() ); cliManager.displayHelp( cliRequest.stdout ); throw e; } // TODO: these should be moved out of here. Wrong place. // if ( cliRequest.commandLine.hasOption( CLIManager.HELP ) ) { cliManager.displayHelp( cliRequest.stdout ); throw new MavenCli.ExitException( 0 ); } if ( cliRequest.commandLine.hasOption( CLIManager.VERSION ) ) { CLIReportingUtils.showVersion( cliRequest.stdout ); throw new MavenCli.ExitException( 0 ); } }
private void cli( CliRequest cliRequest ) throws Exception { CLIManager cliManager = new CLIManager(); try { cliRequest.commandLine = cliManager.parse( cliRequest.args ); } catch ( ParseException e ) { cliRequest.stderr.println( "Unable to parse command line options: " + e.getMessage() ); cliManager.displayHelp( cliRequest.stdout ); throw e; } // TODO: these should be moved out of here. Wrong place. // if ( cliRequest.commandLine.hasOption( CLIManager.HELP ) ) { cliManager.displayHelp( cliRequest.stdout ); throw new MavenCli.ExitException( 0 ); } if ( cliRequest.commandLine.hasOption( CLIManager.VERSION ) ) { CLIReportingUtils.showVersion( cliRequest.stdout ); throw new MavenCli.ExitException( 0 ); } }
private void cli( CliRequest cliRequest ) throws Exception { // // Parsing errors can happen during the processing of the arguments and we prefer not having to check if the logger is null // and construct this so we can use an SLF4J logger everywhere. // slf4jLogger = new Slf4jStdoutLogger(); CLIManager cliManager = new CLIManager(); try { cliRequest.commandLine = cliManager.parse( cliRequest.args ); } catch ( ParseException e ) { System.err.println( "Unable to parse command line options: " + e.getMessage() ); cliManager.displayHelp( System.out ); throw e; } if ( cliRequest.commandLine.hasOption( CLIManager.HELP ) ) { cliManager.displayHelp( System.out ); throw new ExitException( 0 ); } if ( cliRequest.commandLine.hasOption( CLIManager.VERSION ) ) { System.out.println( CLIReportingUtils.showVersion() ); throw new ExitException( 0 ); } }
private void cli( CliRequest cliRequest ) throws Exception { // // Parsing errors can happen during the processing of the arguments and we prefer not having to check if the logger is null // and construct this so we can use an SLF4J logger everywhere. // slf4jLogger = new Slf4jStdoutLogger(); CLIManager cliManager = new CLIManager(); try { cliRequest.commandLine = cliManager.parse( cliRequest.args ); } catch ( ParseException e ) { System.err.println( "Unable to parse command line options: " + e.getMessage() ); cliManager.displayHelp( System.out ); throw e; } if ( cliRequest.commandLine.hasOption( CLIManager.HELP ) ) { cliManager.displayHelp( System.out ); throw new ExitException( 0 ); } if ( cliRequest.commandLine.hasOption( CLIManager.VERSION ) ) { System.out.println( CLIReportingUtils.showVersion() ); throw new ExitException( 0 ); } }
CLIManager cliManager = new CLIManager(); mavenConfig = cliManager.parse( args.toArray( new String[0] ) ); List<?> unrecongized = mavenConfig.getArgList(); if ( !unrecongized.isEmpty() ) cliManager.displayHelp( System.out ); throw e; cliRequest.commandLine = cliManager.parse( cliRequest.args ); cliRequest.commandLine = cliMerge( cliManager.parse( cliRequest.args ), mavenConfig ); cliManager.displayHelp( System.out ); throw e; cliManager.displayHelp( System.out ); throw new ExitException( 0 );