public CellAdapter(String cellName, String cellType, String args) { this(cellName, cellType, new Args(args == null ? "" : args)); }
public CanlSslSocketCreator(String arguments) throws IOException { this(new Args(arguments)); }
public CanlSslServerSocketCreator(String arguments) throws IOException { this(new Args(arguments)); }
public KerberosDssContextFactory(String args) throws GSSException { this(new Args(args)); }
public ServerGsiEngineDssContextFactory(String args) throws Exception { this(new Args(args)); }
/** * Injects the options default values for options into {@code object} using the * Option annotation of fields of {@code <T>}. * * @param object Target object to inject options into. * @param <T> Type of the target object. * @return Returns {@code object}. */ public static <T> T injectDefaults(T object) { return inject(new Args(new String[0]), object); }
public static void main( String [] args ) { if( args.length < 1 ){ System.err.println( "Usage : ... <parseString>" ) ; System.exit(4); } Args lineArgs; if( args.length == 1 ) { lineArgs = new Args(args[0]); } else { lineArgs = new Args(args); } System.out.print( lineArgs.getInfo() ) ; System.out.println( "pvr="+lineArgs.getOpt( "pvr" ) ) ; }
@Override public Cell newCell(StreamEngine engine, String userName) throws InvocationTargetException { try { CellAdapter cell = _loginConstructor.newInstance(_cellName + '-' + userName + '*', engine, new Args(_args)); cell.start().get(); return cell; } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException("Failed to instantiate login cell: " + getName(), e); } catch (ExecutionException | InterruptedException e) { throw new InvocationTargetException(e.getCause(), e.getMessage()); } }
public Args removeOptions(String... names) { ListMultimap<String,String> view = Multimaps.filterKeys(_options, not(in(asList(names)))); return new Args(_arguments, ImmutableListMultimap.copyOf(view), _oneChar); }
public DssServerSocketCreator(String arguments) throws Throwable { Args args = new Args(arguments); Class<? extends DssContextFactory> factory = Class.forName(args.argv(0)).asSubclass(DssContextFactory.class); args.shift(); Constructor<? extends DssContextFactory> cc = factory.getConstructor(String.class); try { this.factory = cc.newInstance(args.toString()); } catch (InvocationTargetException e) { throw e.getCause(); } }
public Object exec( String line ) throws Exception { if (line.trim().isEmpty()) { return ""; } if( _user.equals( "none" ) ) { return command(new Args(line)); } else { return command(new AuthorizedArgs(_user, line)); } } public static void main( String [] args )
@Override public boolean processLine(String line) throws IOException { try { if (echo) { out.println(line); } Args args = new Args(line); if (args.argc() == 0) { return true; } String s = Objects.toString(commandInterpreter.command(args), null); if (!isNullOrEmpty(s)) { out.println(s); } return true; } catch (CommandException e) { throw new IOException(e); } }
private Serializable execAuthorizedString( String user , String command ) throws Exception { if( user == null || user.isEmpty()) { throw new Exception("Not authenticated"); } if (command.trim().isEmpty()) { return ""; } try{ return command( new Args( command + " -auth="+user ) ) ; }catch( CommandPanicException cte ){ throw (Exception)cte.getTargetException() ; }catch( CommandThrowableException cte ){ throw (Exception)cte.getTargetException() ; } } ///////////////////////////////////////////////////////////////////////////
protected void executeDomainContext(String name) { if (name != null) { try { try (Reader in = _nucleus.getDomainContextReader(name)) { CellShell shell = new CellShell(_nucleus, _commandInterpreter); shell.execute("context:" + name, in, new Args("")); } } catch (FileNotFoundException e) { // Ignored: Context variable is not defined } catch (CommandExitException | IOException e) { _log.warn(e.getMessage()); } } }
public static void main( String [] args ){ CommandInterpreter c = new CommandInterpreterTest() ; InputStreamReader reader = new InputStreamReader( System.in ) ; BufferedReader in = new BufferedReader( reader ) ; try{ while( true ){ System.out.print( " > " ) ; String line = in.readLine() ; if( line == null ) { break; } if (line.trim().isEmpty()) { System.out.println(); } else { System.out.println( c.command( new Args( line ) ) ) ; } } }catch( CommandExitException cfe ){ System.out.println( "Command interpreter finished with "+ cfe.getExitCode()+" Message : "+cfe.getMessage() ) ; System.exit(cfe.getExitCode()); }catch( Exception e ){ e.printStackTrace() ; } } //
return command(new Args((String) command)); } else if (command instanceof AuthorizedString) { return command(new AuthorizedArgs((AuthorizedString) command));
private Map<PrincipalMatcher,Set<Principal>> parseMapFile() throws IOException { LOG.debug("Reading file {}", file); Map<PrincipalMatcher,Set<Principal>> map = new LinkedHashMap<>(); int lineCount = 0; for (String line : Files.readAllLines(file)) { lineCount++; line = line.trim(); if (!line.isEmpty() && line.charAt(0) != '#') { try { Args args = new Args(line); checkFormat(args.argc() > 0, "Missing predicate matcher"); checkFormat(args.argc() > 1, "Missing mapped principals"); String matcherDescription = args.argv(0); List<String> mappedPrincipalDescriptions = args.getArguments().subList(1, args.argc()); map.put(asMatcher(matcherDescription), asPrincipals(mappedPrincipalDescriptions)); } catch (GplazmaParseMapFileException e) { warningsConsumer.accept(file.getFileName() + ":" + lineCount + ": " + e.getMessage()); } } } return map; }
private Serializable executeLocalCommand(Object command) throws CommandException { if (command instanceof Authorizable) { if (_returnCommandException) { AuthorizedArgs args = new AuthorizedArgs((Authorizable)command); return command(args); } else { return autoCommand(command); } } else if (command instanceof String) { if (_returnCommandException) { Args args = new Args((String)command); return command(args); } else { return autoCommand(command); } } else { throw new CommandPanicException("Illegal CommandClass detected"); } } private Serializable autoCommand(Object command) {
public Serializable objectCommand2(String strin) { String str; if( ( str = prepareCommand( strin ) ) == null ) { return ""; } try{ Args args = new Args(str); if (args.argc() == 0) { return ""; } Serializable o; if( _externalInterpreter != null ){ o = _externalInterpreter.command(args); }else{ o = command(args); } _errorCode = 0 ; _errorMsg = null ; if( o == null ) { return ""; } return o ; }catch( CommandException ce ){ _errorCode = ce.getErrorCode() ; _errorMsg = ce.getErrorMessage() ; return ce ; } } public Object objectCommand( String strin ) throws CommandExitException {
/** * Start an interactive session. The user is supplied a prompt and * their input is executed as a command. This repeats until they indicate * that they wish to exit the session. */ public void console() throws Throwable { onInteractiveStart(); try { while (true) { String prompt = Ansi.ansi().bold().a(getPrompt()).boldOff().toString(); String str = console.readLine(prompt); if (str == null) { console.println(); break; } execute(new Args(str)); } } catch (CommandExitException ignored) { } }