How to use the thefuck.utils.replace_argument function in thefuck

To help you get started, we’ve selected a few thefuck examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nvbn / thefuck / thefuck / rules / git_add_force.py View on Github external
def get_new_command(command):
    return replace_argument(command.script, 'add', 'add --force')
github nvbn / thefuck / thefuck / rules / git_push.py View on Github external
if upstream_option_index is not None:
        command_parts.pop(upstream_option_index)

        # In case of `git push -u` we don't have next argument:
        if len(command_parts) > upstream_option_index:
            command_parts.pop(upstream_option_index)
    else:
        # the only non-qualified permitted options are the repository and refspec; git's
        # suggestion include them, so they won't be lost, but would be duplicated otherwise.
        push_idx = command_parts.index('push') + 1
        while len(command_parts) > push_idx and command_parts[len(command_parts) - 1][0] != '-':
            command_parts.pop(len(command_parts) - 1)

    arguments = re.findall(r'git push (.*)', command.output)[-1].replace("'", r"\'").strip()
    return replace_argument(" ".join(command_parts), 'push',
                            'push {}'.format(arguments))
github nvbn / thefuck / thefuck / rules / git_fix_stash.py View on Github external
def get_new_command(command):
    stash_cmd = command.script_parts[2]
    fixed = utils.get_closest(stash_cmd, stash_commands, fallback_to_first=False)

    if fixed is not None:
        return replace_argument(command.script, stash_cmd, fixed)
    else:
        cmd = command.script_parts[:]
        cmd.insert(2, 'save')
        return ' '.join(cmd)
github nvbn / thefuck / thefuck / rules / npm_wrong_command.py View on Github external
def get_new_command(command):
    npm_commands = _get_available_commands(command.output)
    wrong_command = _get_wrong_command(command.script_parts)
    fixed = get_closest(wrong_command, npm_commands)
    return replace_argument(command.script, wrong_command, fixed)
github nvbn / thefuck / thefuck / rules / path_from_history.py View on Github external
def get_new_command(command):
    destination = _get_destination(command)
    paths = _get_all_absolute_paths_from_history(command)

    return [replace_argument(command.script, destination, path)
            for path in paths if path.endswith(destination)
            and Path(path).expanduser().exists()]
github nvbn / thefuck / thefuck / rules / git_pull_clone.py View on Github external
def get_new_command(command):
    return replace_argument(command.script, 'pull', 'clone')
github nvbn / thefuck / thefuck / rules / sudo_command_from_user_path.py View on Github external
def get_new_command(command):
    command_name = _get_command_name(command)
    return replace_argument(command.script, command_name,
                            u'env "PATH=$PATH" {}'.format(command_name))
github nvbn / thefuck / thefuck / rules / git_diff_no_index.py View on Github external
def get_new_command(command):
    return replace_argument(command.script, 'diff', 'diff --no-index')
github nvbn / thefuck / thefuck / rules / git_branch_delete.py View on Github external
def get_new_command(command):
    return replace_argument(command.script, '-d', '-D')
github nvbn / thefuck / thefuck / rules / az_cli.py View on Github external
def get_new_command(command):
    mistake = re.search(INVALID_CHOICE, command.output).group(1)
    options = re.findall(OPTIONS, command.output, flags=re.MULTILINE)
    return [replace_argument(command.script, mistake, o) for o in options]