TODO : eventually I will make getCommands and getFormatter more complicated, but for now they work by staying simple
321052
function getCommands( str ){
	var commands = str.split('|');

	commands.forEach(function( command, key ){
		var args = command.split(':');

		args.forEach(function( arg, k ){
			args[k] = trim( arg );
		});

		commands[key] = {
			command: command,
			method: args.shift(),
			args: args
		};
	});

	return commands;
}
506440
public final void mFUNCT() throws RecognitionException {
        try {
            int _type = FUNCT;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:122:6: ( ( 'F' | 'f' ) ( 'U' | 'u' ) ( 'N' | 'n' ) ( 'C' | 'c' ) ( 'T' | 't' ) )
            // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:122:8: ( 'F' | 'f' ) ( 'U' | 'u' ) ( 'N' | 'n' ) ( 'C' | 'c' ) ( 'T' | 't' )
            {
            if ( input.LA(1)=='F'||input.LA(1)=='f' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='U'||input.LA(1)=='u' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='N'||input.LA(1)=='n' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='C'||input.LA(1)=='c' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='T'||input.LA(1)=='t' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        	// do for sure before leaving
        }
    }
1311671
public static void main(String[] args) {
		try {
		  jCommander = new JCommander();
		  	  
		  jCommander.setProgramName("cadmium");
		  
		  HelpCommand helpCommand = new HelpCommand();
		  jCommander.addCommand("help", helpCommand);
      
      Map<String, CliCommand> commands = wireCommands(jCommander);
		  try {
		    jCommander.parse(args);
		  } catch(ParameterException pe) {
		    System.err.println(pe.getMessage());
		    System.exit(1);
		  }
		  
		  String commandName = jCommander.getParsedCommand();
		  if( commandName == null ) {
		    System.out.println("Please use one of the following commands:");
		    for(String command : jCommander.getCommands().keySet() ) {
		      String desc = jCommander.getCommands().get(command).getObjects().get(0).getClass().getAnnotation(Parameters.class).commandDescription();
		      System.out.format("   %16s    -%s\n", command, desc);
		    }
		  } 
		  else if( commandName.equals("help") ) {
			  if( helpCommand.subCommand == null || helpCommand.subCommand.size()==0 ) {
				  jCommander.usage();
				  return;
			  }
			  else {
				 JCommander subCommander = jCommander.getCommands().get(helpCommand.subCommand.get(0));
				 if( subCommander == null ) {
					 System.out.println("Unknown sub command "+commandName);
					 return;
				 }
				 subCommander.usage();
				 return;
			  }
		  } 
		  else if(commands.containsKey(commandName)){
		    CliCommand command = commands.get(commandName);
		    if(command instanceof AuthorizedOnly) {
		      setupSsh(((AuthorizedOnly) command).isAuthQuiet());
		      setupAuth((AuthorizedOnly) command);
		    }
		    command.execute();
		  }
		
		}
		catch( Exception e ) {
			System.err.println("Error: " + e.getMessage());
			logger.debug("Cli Failed", e);
			e.printStackTrace();
			System.exit(1);
		}

	}
1292426
@CommandDescList({
		@CommandDesc(longName = "load",
				description = "load an input bibliography from a file",
				command = ShellLoadCommand.class),
		@CommandDesc(longName = "get",
				description = "get values of shell variables",
				command = ShellGetCommand.class),
		@CommandDesc(longName = "set",
				description = "assign values to shell variables",
				command = ShellSetCommand.class),
		@CommandDesc(longName = "help",
				description = "display help for a given command",
				command = ShellHelpCommand.class),
		@CommandDesc(longName = "exit",
				description = "exit the interactive shell",
				command = ShellExitCommand.class),
		@CommandDesc(longName = "quit",
				description = "exit the interactive shell",
				command = ShellQuitCommand.class),
	})
	public void setCommand(AbstractCSLToolCommand command) {
		//we don't have to do anything here
	}
1117671
public static void main(String[] args)
    {
        // Use the command line parser to evaluate the command line.
        CommandLineParser commandLine =
            new CommandLineParser(
                new String[][]
                {
                    {
                        "s", "The sequence definition.", "[m:...:n](:sample=s)(:exp)", "true", MathUtils.SEQUENCE_REGEXP
                    },
                    { "d", "The duration definition.", "dDhHmMsS", "false", MathUtils.DURATION_REGEXP }
                });

        // Capture the command line arguments or display errors and correct usage and then exit.
        ParsedProperties options = null;

        try
        {
            options = new ParsedProperties(commandLine.parseCommandLine(args));
        }
        catch (IllegalArgumentException e)
        {
            // It is noted that the command line is illegal, so the exception can be ignored.
            e = null;

            System.out.println(commandLine.getErrors());
            System.out.println(commandLine.getUsage());
            System.exit(-1);
        }

        // Extract the command line options.
        String sequence = options.getProperty("s");
        String durationString = options.getProperty("d");

        System.out.println("Sequence is: " + printArray(parseSequence(sequence)));

        if (durationString != null)
        {
            System.out.println("Duration is: " + parseDuration(durationString));
        }
    }
19219
@Override
    protected void doHandle(CommandContext ctx) throws CommandLineException {
        ParsedCommandLine parsedArgs = ctx.getParsedCommandLine();
        final List<String> vars = parsedArgs.getOtherProperties();
        if(vars.isEmpty()) {
            final Collection<String> defined = ctx.getVariables();
            if(defined.isEmpty()) {
                return;
            }
            final List<String> pairs = new ArrayList<String>(defined.size());
            for(String var : defined) {
                pairs.add(var + '=' + ctx.getVariable(var));
            }
            Collections.sort(pairs);
            for(String pair : pairs) {
                ctx.printLine(pair);
            }
            return;
        }
        for(String arg : vars) {
            arg = ArgumentWithValue.resolveValue(arg);
            if(arg.charAt(0) == '$') {
                arg = arg.substring(1);
                if(arg.isEmpty()) {
                    throw new CommandFormatException("Variable name is missing after '$'");
                }
            }
            final int equals = arg.indexOf('=');
            if(equals < 1) {
                throw new CommandFormatException("'=' is missing for variable '" + arg + "'");
            }
            final String name = arg.substring(0, equals);
            if(name.isEmpty()) {
                throw new CommandFormatException("The name is missing in '" + arg + "'");
            }
            if(equals == arg.length() - 1) {
                ctx.setVariable(name, null);
            } else {
                String value = arg.substring(equals + 1);
                if(value.length() > 2 && value.charAt(0) == '`' && value.charAt(value.length() - 1) == '`') {
                    value = Util.getResult(ctx, value.substring(1, value.length() - 1));
                }
                ctx.setVariable(name, value);
            }
        }
    }
952476
public void printUsage(Command command) {
        String commandName = command.getDescriptor().getName();
        StringBuilder sb = new StringBuilder(getSyntaxPrefix()).append(commandName).append(" ");

        // create a list for processed option groups
        Collection<OptionGroup> processedGroups = new ArrayList<>();

        Collection<Option> optList = command.getOptions().getAllOptions();
        if (optList.size() > 1 && getOptionComparator() != null) {
            List<Option> optList2 = new ArrayList<>(optList);
            optList2.sort(getOptionComparator());
            optList = optList2;
        }

        for (Iterator<Option> it = optList.iterator(); it.hasNext();) {
            // get the next Option
            Option option = it.next();
            // check if the option is part of an OptionGroup
            OptionGroup group = command.getOptions().getOptionGroup(option);
            if (group != null) {
                // if the group has not already been processed
                if (!processedGroups.contains(group)) {
                    // add the group to the processed list
                    processedGroups.add(group);
                    // add the usage clause
                    appendOptionGroup(sb, group);
                }
                // otherwise the option was displayed in the group
                // previously so ignore it.
            }
            // if the Option is not part of an OptionGroup
            else {
                appendOption(sb, option, option.isRequired());
            }
            if (it.hasNext()) {
                sb.append(" ");
            }
        }

        for (Arguments arguments : command.getArgumentsList()) {
            sb.append(" ");
            appendArguments(sb, arguments);
        }

        printWrapped(getSyntaxPrefix().length() + commandName.length() + 1, sb.toString());
    }
1204332
@Override
    public String getValue(ParsedCommandLine args) {
        try {
            return getValue(args, false);
        } catch (CommandFormatException e) {
            return null;
        }
    }
926202
function getFormatter(oType) {
		var oFormatOptions;

		if (!oType.oFormat) {
			oFormatOptions = jQuery.extend({strictParsing : true}, oType.oFormatOptions);
			oFormatOptions.UTC = true;
			oType.oFormat = DateFormat.getTimeInstance(oFormatOptions);
		}
		return oType.oFormat;
	}
1130435
private String applyPattern( String key, Object[] messageArguments )
    {
        String message = getString( key );
//        MessageFormat formatter = new MessageFormat( message );
        String output = MessageFormat.format( message, messageArguments );
        return output;
    }
635176
function getKeyBindings(command) {
        var bindings    = [],
            commandID   = "";

        if (!command) {
            console.error("getKeyBindings(): missing required parameter: command");
            return [];
        }

        if (typeof (command) === "string") {
            commandID = command;
        } else {
            commandID = command.getID();
        }

        bindings = _commandMap[commandID];
        return bindings || [];
    }
1165989
private Supplier getFormatterForType(String type) {
    switch(type) {
      case "s":           //string stored in shared table
        if (!lastContents.isEmpty()) {
            int idx = Integer.parseInt(lastContents);
            return new StringSupplier(new XSSFRichTextString(sst.getEntryAt(idx)).toString());
        }
        return new StringSupplier(lastContents);
      case "inlineStr":   //inline string (not in sst)
      case "str":
        return new StringSupplier(new XSSFRichTextString(lastContents).toString());
      case "e":           //error type
        return new StringSupplier("ERROR:  " + lastContents);
      case "n":           //numeric type
        if(currentCell.getNumericFormat() != null && lastContents.length() > 0) {
          // the formatRawCellContents operation incurs a significant overhead on large sheets,
          // and we want to defer the execution of this method until the value is actually needed.
          // it is not needed in all cases..
          final String currentLastContents = lastContents;
          final int currentNumericFormatIndex = currentCell.getNumericFormatIndex();
          final String currentNumericFormat = currentCell.getNumericFormat();

          return new Supplier() {
            String cachedContent;

            @Override
            public Object getContent() {
              if (cachedContent == null) {
                cachedContent = dataFormatter.formatRawCellContents(
                        Double.parseDouble(currentLastContents),
                        currentNumericFormatIndex,
                        currentNumericFormat);
              }

              return cachedContent;
            }
          };
        } else {
          return new StringSupplier(lastContents);
        }
      default:
        return new StringSupplier(lastContents);
    }
  }
1170219
protected static void main(String[] args, CliTool command) {
    JCommander jc = new JCommander(command);
    jc.addConverterFactory(new CustomParameterConverters());
    jc.setProgramName(command.getClass().getAnnotation(Parameters.class).commandNames()[0]);

    ExitStatus exitStatus = ExitStatus.SUCCESS;
    try {
      jc.parse(args);
      if (command.help) {
        helpDisplayCommandOptions(System.err, jc);
      } else {
        exitStatus = command.call();
      }
    } catch (ExitStatusException e) {
      System.err.println(e.getMessage());
      if (e.getCause() != null) {
        e.getCause().printStackTrace(System.err);
      }
      exitStatus = e.exitStatus;
    } catch (MissingCommandException e) {
      System.err.println("Invalid argument: " + e);
      System.err.println();
      helpDisplayCommandOptions(System.err, jc);
      exitStatus = ExitStatus.ERROR_INVALID_ARGUMENTS;
    } catch (ParameterException e) {
      System.err.println("Invalid argument: " + e.getMessage());
      System.err.println();

      if (jc.getParsedCommand() == null) {
        helpDisplayCommandOptions(System.err, jc);
      } else {
        helpDisplayCommandOptions(System.err, jc.getParsedCommand(), jc);
      }
      exitStatus = ExitStatus.ERROR_INVALID_ARGUMENTS;
    } catch (Throwable t) {
      System.err.println("An unhandled exception occurred. Stack trace below.");
      t.printStackTrace(System.err);
      exitStatus = ExitStatus.ERROR_OTHER;
    }

    if (command.callSystemExit) {
      System.exit(exitStatus.code);
    }
  }
355221
private void execCommand(String command,List args) 
		throws NoSuchMethodException,IllegalAccessException,InvocationTargetException
	{
		Class[] template = new Class[ args.size() ];
		for (int i=0; i<args.size(); i++) {
			template[i] = String.class;
		}
		Method m = MatchExptScript.class.getMethod(command, template );
		m.invoke(this, args.toArray(new String[0]));
	}
1205502
async function getHelpContents(args, output) {
    if ('!' in args) {
        return getAllCommands(output);
    }

    if (args._.length == 0) {
        return getGeneralHelpContents(output);
    }
    else if (args._.length == 1) {
        return getVerbHelp(args._[0], output);
    } else if (args._.length >= 2) {
        const serviceManifest = getServiceManifest(args);
        if (serviceManifest) {
            const { operation } = serviceManifest;

            output.write(`${operation.description}\n\n`);
            output.write(`Usage:\n${chalk.cyan.bold(operation.command)}\n\n`);
        } else {
            return getVerbHelp(args._[0], output);
        }
    }

    const serviceManifest = getServiceManifest(args);
    if (serviceManifest) {
        return getHelpContentsForService(serviceManifest, output);
    }

    return getGeneralHelpContents(output);
}
965292
public static void main(String[] args) {
    for (int i = 0; i < args.length; i++)
      System.out.println("'" + args[i] + "' becomes '" + obfuscate(args[i]) + "'");
  }

  /**
   * Takes a string and returns an obfuscated string with no more than 2x a many characters as the
   * original. Only works in the DEV environment.
   */
  public static String obfuscate(String plaintext) {
    String blargtext = StringMan.encodeBytesToString(mangleArray(plaintext.getBytes()));
    blargtext = StringMan.compressHexString(blargtext);
    return blargtext;
  }

  /** Opposite of {@link #obfuscate(String)} */
  public static String clarify(String blargtext) {
    if (blargtext == null)
      return null;
    byte blargBytes[] = decodeStringToBytes(blargtext);
    String plaintext = new String(mangleArray(blargBytes));
    return plaintext;
  }

  /** Inlined from StringManipulator due to static init circular references, called by clarify */
  private static byte[] decodeStringToBytes(String hex) {
    hex = decompressHexString(hex);
    int stringLength = hex.length();
    byte[] b = new byte[stringLength / 2];
    for (int i = 0, j = 0; i < stringLength; i += 2, j++) {
      int high = charToNibble(hex.charAt(i));
      int low = charToNibble(hex.charAt(i + 1));
      b[j] = (byte) ((high << 4) | low);
    }
    return b;
  }

  /** Inlined from StringManipulator due to static init circular references, called by clarify */
  private static int charToNibble(char c) {
    if ('0' <= c && c <= '9')
      return c - '0';
    else if ('a' <= c && c <= 'f')
      return c - 'a' + 0xa;
    else if ('A' <= c && c <= 'F')
      return c - 'A' + 0xa;
    else
      throw new IllegalArgumentException("Invalid hex character: " + c);
  }

  /** Inlined from StringManipulator due to static init circular references, called by clarify */
  private static String decompressHexString(String in) {
    StringBuffer out = new StringBuffer();
    for (int i = 0; i < in.length(); i++) {
      char thisChar = in.charAt(i);
      if (thisChar != '^') {
        out.append(thisChar);
      } else {
        thisChar = in.charAt(i + 1);
        int count = "abcdefghijklmnopqrstuvwxyz01234567890".indexOf(in.charAt(i + 2));
        for (int j = 0; j < count; j++)
          out.append(thisChar);
        i += 2;
      }
    }
    return out.toString();
  }

  /**
   * Takes a given byte array and mangles it by XOR'ing it with a secret garbage hash. It is
   * reversible, so calling mangleArray(mangleArray(blah)) will return the original array.
   * 
   * @return the mangled array (Same size as the input array)
   */
  private static byte[] mangleArray(byte plainBytes[]) {
    if (plainBytes == null)
      return null;
    byte mangled[] = new byte[plainBytes.length];
    byte hash[] = SUPER_SECRET_MANGLE_STRING.getBytes();
    for (int i = 0; i < plainBytes.length; i++) {
      byte current = (byte) (plainBytes[i] ^ hash[i % hash.length]);
      mangled[i] = current;
    }
    return mangled;
  }

}
1255104
private <T extends CommandType> T getCommand() {
        if (command == null) {
            if (getPayload() instanceof String) {
                this.command = (T) marshaller.unmarshal(new StringSource(getPayload(String.class)));
            }
        }

        return (T) command;
    }