generates command and parameter completions
509706
def gen_cmd_and_param_completions(self):
        
        if self.complete_command:
            for param in self.command_param_info.get(self.current_command, []):
                if self.validate_param_completion(param, self.leftover_args):
                    yield self.yield_param_completion(param, self.unfinished_word)
        elif not self.leftover_args:
            for child_command in self.subtree.children:
                if self.validate_completion(child_command):
                    yield Completion(child_command, -len(self.unfinished_word))
582254
def complete(self, text, state):
        """"""
        result = cmd.Cmd.complete(self, text, state)
        if self.argparser_completer:
            self._make_argparser()
            # argparser screws up with internal states, this is the best way to fix it for now
        return result
1140364
def completion():
    
    shell = env.get("SHELL", None)
    if env.get("SHELL", None):
        echo(
            click_completion.get_code(
                shell=shell.split(os.sep)[-1], prog_name="doitlive"
            )
        )
    else:
        echo(
            "Please ensure that the {SHELL} environment "
            "variable is set.".format(SHELL=style("SHELL", bold=True))
        )
        sys.exit(1)
166173
def generate_command(name, tty_options)
      cmd = []
      cmd << name
      cmd += tty_options
      cmd << "`#{find_filters.join(' | ')}`"
      cmd.join(' ')
    end
62689
def _bashcomplete(cmd, prog_name, complete_var=None):
    """"""
    if complete_var is None:
        complete_var = '_%s_COMPLETE' % (prog_name.replace('-', '_')).upper()
    complete_instr = os.environ.get(complete_var)
    if not complete_instr:
        return

    from ._bashcomplete import bashcomplete
    if bashcomplete(cmd, prog_name, complete_var, complete_instr):
        sys.exit(1)
231380
def generate_command(self):
        
        example = []
        example.append(f"{sys.argv[0]}")
        for key in sorted(list(self.spec.keys())):
            if self.spec[key]['type'] == list:
                value = " ".join(self.spec[key].get('example', ''))
            elif self.spec[key]['type'] == dict:
                value = f"\'{json.dumps(self.spec[key].get('example', ''))}\'"
            else:
                value = self.spec[key].get('example', '')
            string = f"     --{key.lower()} {value}"
            example.append(string)
        print(" \\\n".join(example))
691479
function completionHandler(currentInput, currentArgv) {
    commandExecuted = true
    const {scripts} = getPSConfig(currentArgv) || {}
    if (scripts) {
      return getCompletionScripts(scripts, currentInput)
    }
    return []
  }
476814
def complete(text, state):
    ''''''
    global last_clist
    global rline_mpstate
    if state != 0 and last_clist is not None:
        return last_clist[state]

    # split the command so far
    cmd = readline.get_line_buffer().split()

    if len(cmd) == 1:
        # if on first part then complete on commands and aliases
        last_clist = complete_command(text) + complete_alias(text)
    elif cmd[0] in rline_mpstate.completions:
        # we have a completion rule for this command
        last_clist = complete_rules(rline_mpstate.completions[cmd[0]], cmd[1:])
    else:
        # assume completion by filename
        last_clist = glob.glob(text+'*')
    ret = []
    for c in last_clist:
        if c.startswith(text) or c.startswith(text.upper()):
            ret.append(c)
    if len(ret) == 0:
        # if we had no matches then try case insensitively
        text = text.lower()
        for c in last_clist:
            if c.lower().startswith(text):
                ret.append(c)
    ret.append(None)
    last_clist = ret
    return last_clist[state]
469929
function _createAutocomplete(session) {
    return function(args, callback) {
        args = args.slice();

        // First handle the case where this is an auto-suggest based on finding the command name
        var allCommandNames = _.keys(session.commands().get());
        if (_.isEmpty(args)) {
            return callback(null, allCommandNames);
        } else if (args.length === 1) {
            return callback(null, _.filter(allCommandNames, function(commandName) {
                return (commandName.indexOf(args[0]) === 0);
            }));
        }

        // We presumably have a command argument already, feed the remaining arguments into the
        // commands autocomplete implementation
        var commandName = args.shift();
        var command = session.commands().get(commandName);
        if (command && _.isFunction(command.autocomplete)) {
            return command.autocomplete(session, args, callback);
        }

        return callback(null, []);
    };
}
133789
def generate_completions(event):
    
    """
    b = event.current_buffer

    # When already navigating through completions, select the next one.
    if b.complete_state:
        b.complete_next()
    else:
        event.cli.start_completion(insert_common_part=True, select_first=False)
1314318
def generate_help_text():
    
    def generate_cmds_with_explanations(summary, cmds):
        text = '{0}:\n'.format(summary)
        for cmd, explanation in cmds:
            text += '\t{0:<10}\t{1:<20}\n'.format(cmd, explanation)
        return text + '\n'

    text = generate_cmds_with_explanations('Commands', ROOT_COMMANDS.items())
    text += generate_cmds_with_explanations('Options', OPTION_NAMES.items())
    text += generate_cmds_with_explanations('Actions', ACTIONS.items())
    text += generate_cmds_with_explanations('Headers', HEADER_NAMES.items())
    return text
55793
function generate(path, command, template) {
        var paths = getPaths(path);
        template = template || fs_1.readFileSync(// read in our script template.
        path_1.resolve(constants_1.PARGV_ROOT, 'completion.sh.tpl'), 'utf-8');
        template = template.replace(/{{app_name}}/g, paths.appName); // replace app name.
        template = template.replace(/{{app_reply_command}}/g, command); // replace the command.
        var script = template.replace(/{{app_path}}/g, paths.appPath); // replace the path.
        var sourceScript = srcTpl;
        sourceScript = sourceScript.replace(/{{app_name}}/g, paths.appName);
        sourceScript = sourceScript.replace(/{{app_completions_path}}/g, paths.completionsPath);
        return {
            paths: paths,
            command: command,
            script: script,
            sourceScript: sourceScript
        };
    }
455394
def gen_cmake_command(config):
    
    from autocmake.extract import extract_list

    s = []
    s.append("\n\ndef gen_cmake_command(options, arguments):")
    s.append('    """')
    s.append("    Generate CMake command based on options and arguments.")
    s.append('    """')
    s.append("    command = []")

    for env in config['export']:
        s.append('    command.append({0})'.format(env))

    s.append("    command.append(arguments['--cmake-executable'])")

    for definition in config['define']:
        s.append('    command.append({0})'.format(definition))

    s.append("    command.append('-DCMAKE_BUILD_TYPE={0}'.format(arguments['--type']))")
    s.append("    command.append('-G\"{0}\"'.format(arguments['--generator']))")
    s.append("    if arguments['--cmake-options'] != \"''\":")
    s.append("        command.append(arguments['--cmake-options'])")
    s.append("    if arguments['--prefix']:")
    s.append("        command.append('-DCMAKE_INSTALL_PREFIX=\"{0}\"'.format(arguments['--prefix']))")

    s.append("\n    return ' '.join(command)")

    return '\n'.join(s)
644014
def yield_param_completion(self, param, last_word):
        
        return Completion(param, -len(last_word), display_meta=self.param_description.get(
            self.current_command + " " + str(param), '').replace(os.linesep, ''))
236096
def complete_help_subcommand(self, text: str, line: str, begidx: int, endidx: int) -> List[str]:
        """"""

        # Get all tokens through the one being completed
        tokens, _ = self.tokens_for_completion(line, begidx, endidx)

        if not tokens:
            return []

        # Must have at least 3 args for 'help command sub-command'
        if len(tokens) < 3:
            return []

        # Find where the command is by skipping past any flags
        cmd_index = 1
        for cur_token in tokens[cmd_index:]:
            if not cur_token.startswith('-'):
                break
            cmd_index += 1

        if cmd_index >= len(tokens):
            return []

        command = tokens[cmd_index]
        matches = []

        # Check if this is a command with an argparse function
        func = self.cmd_func(command)
        if func and hasattr(func, 'argparser'):
            completer = AutoCompleter(getattr(func, 'argparser'), self)
            matches = completer.complete_command_help(tokens[cmd_index:], text, line, begidx, endidx)

        return matches
1285490
def _click_autocomplete(root, text):
    """"""
    try:
        parts = shlex.split(text)
    except ValueError:
        raise StopIteration

    location, incomplete = _click_resolve_command(root, parts)

    if not text.endswith(' ') and not incomplete and text:
        raise StopIteration

    if incomplete and not incomplete[0:2].isalnum():
        for param in location.params:
            if not isinstance(param, click.Option):
                continue
            for opt in itertools.chain(param.opts, param.secondary_opts):
                if opt.startswith(incomplete):
                    yield completion.Completion(opt, -len(incomplete), display_meta=param.help)

    elif isinstance(location, (click.MultiCommand, click.core.Group)):
        ctx = click.Context(location)
        commands = location.list_commands(ctx)
        for command in commands:
            if command.startswith(incomplete):
                cmd = location.get_command(ctx, command)
                yield completion.Completion(command, -len(incomplete), display_meta=cmd.short_help)
401280
def _doCommandCompletion(self):
                
        prefix =  ''.join(self.inputBuffer).strip().upper()
        matches = self.completion.keys(prefix)
        matchLen = len(matches)        
        if matchLen == 0 and prefix[-1] == '=':
            try:                
                command = prefix[:-1]
            except KeyError:
                pass                        
            else:
                self.__printCommandSyntax(command)
        elif matchLen > 0:                        
            if matchLen == 1:
                if matches[0] == prefix:
                    # User has already entered command - show command syntax
                    self.__printCommandSyntax(prefix)
                else:
                    # Complete only possible command
                    self.inputBuffer = list(matches[0])
                    self.cursorPos = len(self.inputBuffer)
                    self._refreshInputPrompt(len(self.inputBuffer))
                return
            else:
                commonPrefix = self.completion.longestCommonPrefix(''.join(self.inputBuffer))
                self.inputBuffer = list(commonPrefix)
                self.cursorPos = len(self.inputBuffer)
                if matchLen > 20:
                    matches = matches[:20]
                    matches.append('... ({0} more)'.format(matchLen - 20))
            sys.stdout.write('\n')
            for match in matches:
                sys.stdout.write(' {0} '.format(match))
            sys.stdout.write('\n')
            sys.stdout.flush()
            self._refreshInputPrompt(len(self.inputBuffer))