TODO: Extract this method into separate class that gives all
 the involved parties the chance to parse all of the args
17979
def parse(args)
      if args[0] =~ /^(--help|help)$/
        first, *rest = args
        if rest.empty?
          puts banner
        else
          puts commands[rest.first].help
        end
      elsif cmd = args.find { |el| commands.has_command?(el) }
        cmd_idx = args.index(cmd)
        top_args, cmd_args = args.partition.with_index do |_arg, idx|
          idx < cmd_idx
        end
        top.parse(top_args)
        remainder = commands[cmd].parse(cmd_args[1..-1])
      else
        if args.empty?
          puts banner
        else
          remainder = top.parse(args)
        end
      end

      [cmd || name, arguments, remainder || []]
    end
514563
def parse_args():
    
    parser = argparse.ArgumentParser()
    parser.add_argument('-M', action='store_true')
    parser.add_argument('-m', action='store_true')
    parser.add_argument('-f', action='store_true')
    args = parser.parse_args()
    major, minor, fix = args.M, args.m, args.f
    if major + minor + fix != 1:
        fail('Please select one and only one action.')
    return major, minor, fix
1139484
static void processArgs(String[] args, final PrintStream out) {
        Options options = buildOptions();

        try {
            CommandLine cmd = parseCommandLine(options, args);

            if (cmd.hasOption('h')) {
                printHelp(out, options);
            } else if (cmd.hasOption('v')) {
                String version = GroovySystem.getVersion();
                out.println("Groovy Version: " + version + " JVM: " + System.getProperty("java.version") + 
                        " Vendor: " + System.getProperty("java.vm.vendor")  + " OS: " + System.getProperty("os.name"));
            } else {
                // If we fail, then exit with an error so scripting frameworks can catch it
                // TODO: pass printstream(s) down through process
                if (!process(cmd)) {
                    System.exit(1);
                }
            }
        } catch (ParseException pe) {
            out.println("error: " + pe.getMessage());
            printHelp(out, options);
        } catch (IOException ioe) {
            out.println("error: " + ioe.getMessage());
        }
    }
870048
def method_missing(name, *args, &block)
      getter_name = name[0..-2]

      if name =~ /^[a-z]+=$/ && !respond_to?(getter_name)
        define_accessor(getter_name, args.first)
      else
        super
      end
    end
1102246
function parseArgs() {
    var args = Array.prototype.slice.call(arguments);

    var ret = {
        query: args[0],
        params: [],
        options: {},
        callback: undefined,
        endCallback: undefined
    };

    args.shift();

    // If specified, params must be an array
    if (args[0] instanceof Array) {
        ret.params = args[0];
        args.shift();
    }

    // If specified, options must be a non-Function object
    if (! (args[0] instanceof Function)) {
        ret.options = args[0];
        args.shift();
    }

    ret.callback = args[0];
    ret.endCallback = args[1];

    if (ret.query === undefined || ret.callback === undefined) {
        throw new Error('query and callback are required');
    }

    return ret;
}
703311
def parse_args
      parser = Trollop::Parser.new do
        opt :list
        opt :add, "", :type => :string
        opt :remove, "", :type => :string
        opt :query, "", :type => :strings
        opt :verbose
        opt :die, "", :short => "-e"
        opt :format, "", :type => :string, :default => "json"
        opt :timeout, "", :type => :int, :default => TAG_REQUEST_TIMEOUT
        version ""
      end

      parse do
        options = parser.parse
        options[:action] = :get_tags if options.delete(:list)
        if options[:add]
          options[:action] = :add_tag
          options[:tag] = options.delete(:add).strip
          raise ::Trollop::CommandlineError.new("Non-empty value required") if options[:tag].empty?
        end
        if options[:remove]
          options[:action] = :remove_tag
          options[:tag] = options.delete(:remove).strip
          raise ::Trollop::CommandlineError.new("Non-empty value required") if options[:tag].empty?
        end
        if options[:query]
          options[:action] = :query_tags
          options[:tags] = options.delete(:query).map { |tag| tag.strip }
        end
        options[:format] = parse_format(options[:format])
        options
      end
    end
304987
def parse_args():
    
    parser = argparse.ArgumentParser()
    parser.add_argument('--lint',
                        help='Path to the ADT lint tool. If not specified it assumes lint tool is in your path',
                        default='lint')
    parser.add_argument('--app',
                        help='Path to the Android app. If not specifies it assumes current directory is your Android '
                             'app directory',
                        default='.')
    parser.add_argument('--xml',
                        help='Path to the lint result. If not specifies linting will be done by the script',
                        default=None)
    parser.add_argument('--ignore-layouts',
                        help='Should ignore layouts',
                        action='store_true')
    args = parser.parse_args()
    return args.lint, args.app, args.xml, args.ignore_layouts
1345516
public void parse(ArgumentList args) {
        try {
            parseInternal(args);
        } catch (ArgumentException e) {
            if (e.getParser() == null) {
                e.setParser(this);
            }
            throw e;
        }
    }
1362185
function collectArguments() {
  var args = arguments, i = args.length, arr = new Array(i);
  while (i--) {
    arr[i] = args[i];
  }
  return arr;
}
354301
def to_param(args)
        case args
        when String
          define_method "to_param" do
            args.gsub(/:(\w+)/) {|method| send(method[1..-1]).to_s.parameterize }
          end

          if args.empty?
            raise ArgumentError.new("args can not be an empty string")
          end
        when Symbol
          define_method "to_param" do
            "#{id}-#{send(args).parameterize}"
          end
        else
          raise ArgumentError.new("args can only be string or symbol")
        end
    end
66061
def arguments(args = nil)
      return @_arguments if args.nil?
      @_arguments = []
      [*args].map(&:split).flatten.each do |arg|
        @_arguments << Clin::Argument.new(arg)
      end
    end
953748
private void handleMainMethodIfPresent(List methods) {
        boolean found = false;
        for (Iterator iter = methods.iterator(); iter.hasNext();) {
            MethodNode node = (MethodNode) iter.next();
            if(node.getName().equals("main")) {
                if (node.isStatic() && node.getParameters().length == 1) {
                    boolean retTypeMatches, argTypeMatches;
                    ClassNode argType = node.getParameters()[0].getType();
                    ClassNode retType = node.getReturnType();

                    argTypeMatches = (argType.equals(ClassHelper.OBJECT_TYPE) || argType.getName().contains("String[]"));
                    retTypeMatches = (retType == ClassHelper.VOID_TYPE || retType == ClassHelper.OBJECT_TYPE);
                    
                    if(retTypeMatches && argTypeMatches) {
                        if(found) {
                            throw new RuntimeException("Repetitive main method found.");
                        } else {
                            found = true;
                        }
                        // if script has both loose statements as well as main(), then main() is ignored
                        if(statementBlock.isEmpty()) {
                            addStatement(node.getCode());
                        }
                        iter.remove();
                    }
                }
            }
        }
    }
540121
def parse(self, *args, **kwargs):  # pylint: disable=unused-argument
        
        # pylint: disable=W0703
        cmd = args[0]
        resp = args[1]
        if cmd in self.parsers:
            try:
                return self.parsers[cmd](resp)
            except Exception as err:
                print(err)
        return {}
50837
def get_args_names(method)
      args = method.args
      args_names = ' '
      args.each_with_index { |a, i|args_names << "${#{i + 1}:#{a}}, " }
      args_names.chop!.chop! unless args.empty?
    end
716406
def load_from_args(active_relation_or_array,*args)
      options = args.extract_options!
      @name = (options[:name] || Time.now.strftime("%Y_%m_%d_%H_%M_%S")).to_sym
      if active_relation_or_array.kind_of? String
        @extract_code = active_relation_or_array
      else
        raise "Extract code must be a string, so .rebuild can be called"
      end
    end
529442
def parse_args
      options = { :agent_name => 'instance', :verbose => false }

      parser = Trollop::Parser.new do
        opt :level, "", :type => String, :long => "--log-level", :short => "-l"
        opt :agent
        opt :verbose
        version ""
      end

      parse do
        options.merge!(parser.parse)
        if options[:level]
          fail("Invalid log level '#{options[:level]}'") unless AgentManager::LEVELS.include?(options[:level].to_sym)
        end
        options
      end
    end
460808
public static void main(String[] args)
    {
        Class<?> exampleClass = args.length > 0 ? EXAMPLES.get(args[0]) : null;
        if (exampleClass == null)
        {
            System.err.println("First argument must be the name of an example, i.e. one of "
                               + Arrays.toString(EXAMPLES.keySet().toArray()));
            System.exit(1);
        }

        // All args except the first one should be passed to the example application.
        String[] appArgs = new String[args.length - 1];
        System.arraycopy(args, 1, appArgs, 0, appArgs.length);

        // Invoke the main method for the selected example application.
        Method main = ReflectionUtils.findKnownMethod(exampleClass, "main", String[].class);
        ReflectionUtils.invokeUnchecked(main, exampleClass, new Object[]{appArgs});
    }