List of usage examples for org.apache.commons.cli AlreadySelectedException getLocalizedMessage
public String getLocalizedMessage()
From source file:nl.cyso.vcloud.client.config.Configuration.java
public static CommandLine parseCli(ModeType mode, String[] args) { CommandLine cli = null;//from ww w . j av a 2 s.co m Options opt = ConfigModes.getMode(mode); try { cli = new IgnorePosixParser(true).parse(opt, args); } catch (MissingArgumentException me) { Formatter.usageError(me.getLocalizedMessage(), mode); System.exit(-1); } catch (MissingOptionException mo) { Formatter.usageError(mo.getLocalizedMessage(), mode); System.exit(-1); } catch (AlreadySelectedException ase) { Formatter.usageError(ase.getLocalizedMessage(), mode); } catch (UnrecognizedOptionException uoe) { Formatter.usageError(uoe.getLocalizedMessage(), mode); } catch (ParseException e) { Formatter.printStackTrace(e); System.exit(-1); } return cli; }
From source file:nl.cyso.vsphere.client.config.Configuration.java
public static CommandLine parseCli(String mode, String[] args, boolean dieOnFailure) throws Exception { CommandLine cli = null;//from w ww .j av a2 s . c o m Options opt = ConfigModes.getMode(mode); Throwable die = null; try { cli = new IgnorePosixParser(true).parse(opt, args); } catch (MissingArgumentException me) { Formatter.usageError(me.getLocalizedMessage(), mode, false); die = me; } catch (MissingOptionException mo) { Formatter.usageError(mo.getLocalizedMessage(), mode, false); die = mo; } catch (AlreadySelectedException ase) { Formatter.usageError(ase.getLocalizedMessage(), mode, false); die = ase; } catch (UnrecognizedOptionException uoe) { Formatter.usageError(uoe.getLocalizedMessage(), mode, false); die = uoe; } catch (ParseException e) { Formatter.printStackTrace(e); die = e; } if (dieOnFailure && die != null) { System.exit(-1); } else if (!dieOnFailure && die != null) { throw new Exception("Failed to initialize Configuration", die); } return cli; }