Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add choco_install rule #998

Merged
merged 7 commits into from
Nov 7, 2019
Merged

Add choco_install rule #998

merged 7 commits into from
Nov 7, 2019

Conversation

philiparola
Copy link
Contributor

@philiparola philiparola commented Oct 29, 2019

Adds a rule to append '.install' to a chocolatey install command that
failed because of a non-existent package.

Adds a rule to append '.install' to a chocolatey install command that
failed because of a non-existent package.

TODO: add support for other suffixes (.portable), find more parameter
cases
Copy link
Collaborator

@scorphus scorphus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rule needs a complete refactor and should be rewritten as such:

from thefuck.utils import for_app, which


@for_app("choco", "cinst")
def match(command):
    return (
        command.script.startswith("choco install") or "cinst" in command.script_parts
    ) and "Installing the following packages" in command.output


def get_new_command(command):
    for script_part in command.script_parts:
        if (
            "choco" not in script_part
            and "cinst" not in script_part
            and "install" not in script_part
            and not script_part.startswith("-")
            and "=" not in script_part
            and "/" not in script_part
        ):
            return command.script.replace(script_part, script_part + ".install")
    return []


enabled_by_default = bool(which("choco")) or bool(which("cinst"))

With a comprehensive set of test cases.

Taking all this into consideration, In the meantime, it's being labeled as invalid.

@philiparola philiparola requested a review from scorphus October 30, 2019 18:19
Copy link
Collaborator

@scorphus scorphus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests for match are still missing. Check other tests for reference.

@scorphus scorphus added windows and removed invalid labels Oct 31, 2019
@philiparola philiparola requested a review from scorphus November 3, 2019 04:34
@scorphus
Copy link
Collaborator

scorphus commented Nov 3, 2019

Thanks for your contribution, @philiparola!

@nvbn
Copy link
Owner

nvbn commented Nov 7, 2019

Looks good, thanks!

@nvbn nvbn merged commit d10fc80 into nvbn:master Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants