find command name. it is first argument.
552328
protected function findCommand(): void
    {
        if (!isset($this->args[0])) {
            return;
        }

        $newArgs = [];

        foreach ($this->args as $key => $value) {
            if ($key === 0) {
                $this->command = \trim($value);
            } elseif (\is_int($key)) {
                $newArgs[] = $value;
            } else {
                $newArgs[$key] = $value;
            }
        }

        $this->args = $newArgs;
    }
949036
def get_command(self, ctx, name):
        """"""
        if not self._commands_dir:
            return defaults.get_command(ctx, name)

        ns = {}
        fn = os.path.join(self._commands_dir, name + '.py')

        try:
            with open(fn) as f:
                code = compile(f.read(), fn, 'exec')
        except IOError:
            return defaults.get_command(ctx, name)

        eval(code, ns, ns)

        CLI = 'cli'

        try:
            return ns[CLI]
        except KeyError:
            ctx.fail('`{}` not defined in "{}"'.format(CLI, name))
1005583
def get_argv_for_command(self):
        
        argv = [a for a in self.argv]
        argv.insert(0, self.prog_name)
        return argv
1353321
def get_command(arguments):
    
    return [k for k, v in arguments.items()
            if not k.startswith('-') and v is True][0]
35615
function getCommand(argv) {
  let command = argv._[0] || 'help';

  // Allow shorthand "-v" for version
  if (argv.v) {
    command = 'version';
  }

  // Allow shorthand "-h" for help
  if (argv.h) {
    command = 'help';
  }

  return command;
}
1167058
def name(self, *args):
        '''
        
        '''
        if len(args):
            self.__name = args[0]
        else:
            return self.__name
480116
function nameOfCommand(cmd) {
  if (!cmd) return "no command!";
  if (Array.isArray(cmd)) return nameOfCommand(cmd[0]);
  if (typeof cmd === "string") return cmd;
  if (cmd.name) return cmd.name;
  if (cmd.command) return cmd.command;
  return "unknown command, no name";
}
1316753
def list_commands(self, ctx):
        """"""
        rv = defaults.list_commands(ctx)
        if self._commands_dir:
            for filename in os.listdir(self._commands_dir):
                if _is_command_file(filename) and filename[:-3] not in rv:
                    rv.append(filename[:-3])
            rv.sort()
        return rv
64772
public static function findCommandLong($arg) {
		foreach (self::$commands as $command => $commandOptions) {
			if (($commandOptions["commandLong"] == $arg) || ($commandOptions["commandShort"] == $arg)) {
				return $command;
			}
		}
		return false;
	}
77139
def find_match_command(self, rule):
        """"""

        command_string = rule['command']
        command_list = command_string.split()

        self.logdebug('comparing "%s" to "%s"\n' %
                      (command_list, self.original_command_list))
        if rule.get('allow_trailing_args'):
            self.logdebug('allow_trailing_args is true - comparing initial '
                          'list.\n')
            # Verify the initial arguments are all the same
            if (self.original_command_list[:len(command_list)] ==
                    command_list):
                self.logdebug('initial list is same\n')
                return {'command': self.original_command_list}
            else:
                self.logdebug('initial list is not same\n')

        elif rule.get('pcre_match'):
            if re.search(command_string, self.original_command_string):
                return {'command': self.original_command_list}

        elif command_list == self.original_command_list:
            return {'command': command_list}
1186398
def find_command(cmd, args = [])
      @current_cmd = cmd
      @current_args = args

      respond_with_help if seeking_help?
      respond_with_version if seeking_version?

      # Separate out primary/secondary commands based on if command was namespaced
      # e.g. `conify services vs. conify services:add`
      primary_cmd, secondary_cmd = @current_cmd.split(':')

      # Get the command file path (string) for the primary command
      primary_cmd_file = file_for_command(primary_cmd)

      # If the primary command has it's own file, require it
      primary_cmd_file_exists = File.exists?(primary_cmd_file)
      require primary_cmd_file if primary_cmd_file_exists

      # If a secondary command exists, the primary_cmd_file must be where our command method lies
      if !secondary_cmd.nil?
        error_no_command if !primary_cmd_file_exists

        # Get command_klass for file path. Example response --> Conify::Command::Services
        command_klass = klass_for_file(primary_cmd_file)

        # Error out if the command klass doesn't have a method named <secondary_cmd>
        error_no_command if !klass_has_method?(command_klass, secondary_cmd)

        run(command_klass, secondary_cmd)

      # If there's no secondary command, there are 2 options for where the command method could be (in order of priority):
      # (1) Inside the primary command file as the 'index' method
      # (2) Inside the global command file, as a method named <primary_cmd>
      else
        # Store lambda for later
        try_global = lambda {
          require 'conify/command/global'
          command_klass = Conify::Command::Global
          error_no_command if !klass_has_method?(command_klass, primary_cmd)
          run(command_klass, primary_cmd)
        }

        # Number 1 above. If primary_cmd file exists, call the index method on it if it exists.
        # If index method doens't exist, check to see if method is a global command.
        if primary_cmd_file_exists
          # Get command_klass for file path. Example response --> Conify::Command::Services
          command_klass = klass_for_file(primary_cmd_file)

          klass_has_method?(command_klass, 'index') ? run(command_klass, 'index') : try_global.call

        # Number 2 above. Check to see if method is a global command inside command/global.rb
        else
          try_global.call
        end
      end
    end
951153
def get_command(self, ctx, cmd_name):
        
        if cmd_name not in self._commands:
            logger.error("Command %s not available", cmd_name)
            return

        pkg_name = self._commands[cmd_name]

        try:
            mod = importlib.import_module(pkg_name)
        except ImportError:
            logger.exception("Command '%s' is not configured correctly. Unable to import '%s'", cmd_name, pkg_name)
            return

        if not hasattr(mod, "cli"):
            logger.error("Command %s is not configured correctly. It must expose an function called 'cli'", cmd_name)
            return

        return mod.cli
372636
def get_command(self, ctx, cmd_name):
        """"""
        rv = click.Group.get_command(self, ctx, cmd_name)
        if rv is not None:
            return rv
        cmd_name = self.command_aliases.get(cmd_name, "")
        return click.Group.get_command(self, ctx, cmd_name)
74433
def find_command(cmd, paths = [])
      exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
      paths += ENV['PATH'].split(File::PATH_SEPARATOR)
      paths.each do |path|
        exts.each do |ext|
          exe = File.join(path, "#{cmd}#{ext}")
          if (File.executable?(exe) && File.file?(exe))
            return Shellwords.escape exe
          end
        end
      end
      nil
    end
1209133
def get_proc_name(cmd):
    
    if isinstance(cmd, Iterable) and not isinstance(cmd, str):
        cmd = " ".join(cmd)

    return cmd.split()[0].replace('(', '').replace(')', '')
1105378
public static Name getFirstArgumentAsName(Object[] args) {
        Assert.notEmpty(args);

        Object firstArg = args[0];
        return getArgumentAsName(firstArg);
    }
512394
def find_first(self, name=None, ns_uri=None):
        
        return self.find(name=name, ns_uri=ns_uri, first_only=True)