# Path: thefuck/rules/remove_shell_prompt_literal.py
# def match(command):
#     return (
#         "$: command not found" in command.output
#         and re.search(r"^[\s]*\$ [\S]+", command.script) is not None
#     )
# 
# def get_new_command(command):
#     return command.script.lstrip("$ ")
# 
# Path: thefuck/types.py
# class Command(object):
#     """Command that should be fixed."""
# 
#     def __init__(self, script, output):
#         """Initializes command with given values.
# 
#         :type script: basestring
#         :type output: basestring
# 
#         """
#         self.script = script
#         self.output = output
# 
#     @property
#     def stdout(self):
#         logs.warn('`stdout` is deprecated, please use `output` instead')
#         return self.output
# 
#     @property
#     def stderr(self):
#         logs.warn('`stderr` is deprecated, please use `output` instead')
#         return self.output
# 
#     @property
#     def script_parts(self):
#         if not hasattr(self, '_script_parts'):
#             try:
#                 self._script_parts = shell.split_command(self.script)
#             except Exception:
#                 logs.debug(u"Can't split command script {} because:\n {}".format(
#                     self, sys.exc_info()))
#                 self._script_parts = []
# 
#         return self._script_parts
# 
#     def __eq__(self, other):
#         if isinstance(other, Command):
#             return (self.script, self.output) == (other.script, other.output)
#         else:
#             return False
# 
#     def __repr__(self):
#         return u'Command(script={}, output={})'.format(
#             self.script, self.output)
# 
#     def update(self, **kwargs):
#         """Returns new command with replaced fields.
# 
#         :rtype: Command
# 
#         """
#         kwargs.setdefault('script', self.script)
#         kwargs.setdefault('output', self.output)
#         return Command(**kwargs)
# 
#     @classmethod
#     def from_raw_script(cls, raw_script):
#         """Creates instance of `Command` from a list of script parts.
# 
#         :type raw_script: [basestring]
#         :rtype: Command
#         :raises: EmptyCommand
# 
#         """
#         script = format_raw_script(raw_script)
#         if not script:
#             raise EmptyCommand
# 
#         expanded = shell.from_shell(script)
#         output = get_output(script, expanded)
#         return cls(expanded, output)


import pytest
from thefuck.rules.remove_shell_prompt_literal import match, get_new_command
from thefuck.types import Command


@pytest.fixture
def output():
    return "$: command not found"


@pytest.mark.parametrize(
    "script",
    [
        "$ cd newdir",
        " $ cd newdir",
        "$ $ cd newdir",
        " $ $ cd newdir",
    ],
)
def test_match(script, output):
    assert match(Command(script, output))


@pytest.mark.parametrize(
    "command",
    [
        Command("$", "$: command not found"),
        Command(" $", "$: command not found"),
        Command("$?", "127: command not found"),
        Command(" $?", "127: command not found"),

# Path: thefuck/rules/remove_shell_prompt_literal.py
# def match(command):
#     return (
#         "$: command not found" in command.output
#         and re.search(r"^[\s]*\$ [\S]+", command.script) is not None
#     )
# 
# def get_new_command(command):
#     return command.script.lstrip("$ ")
# 
# Path: thefuck/types.py
# class Command(object):
#     """Command that should be fixed."""
# 
#     def __init__(self, script, output):
#         """Initializes command with given values.
# 
#         :type script: basestring
#         :type output: basestring
# 
#         """
#         self.script = script
#         self.output = output
# 
#     @property
#     def stdout(self):
#         logs.warn('`stdout` is deprecated, please use `output` instead')
#         return self.output
# 
#     @property
#     def stderr(self):
#         logs.warn('`stderr` is deprecated, please use `output` instead')
#         return self.output
# 
#     @property
#     def script_parts(self):
#         if not hasattr(self, '_script_parts'):
#             try:
#                 self._script_parts = shell.split_command(self.script)
#             except Exception:
#                 logs.debug(u"Can't split command script {} because:\n {}".format(
#                     self, sys.exc_info()))
#                 self._script_parts = []
# 
#         return self._script_parts
# 
#     def __eq__(self, other):
#         if isinstance(other, Command):
#             return (self.script, self.output) == (other.script, other.output)
#         else:
#             return False
# 
#     def __repr__(self):
#         return u'Command(script={}, output={})'.format(
#             self.script, self.output)
# 
#     def update(self, **kwargs):
#         """Returns new command with replaced fields.
# 
#         :rtype: Command
# 
#         """
#         kwargs.setdefault('script', self.script)
#         kwargs.setdefault('output', self.output)
#         return Command(**kwargs)
# 
#     @classmethod
#     def from_raw_script(cls, raw_script):
#         """Creates instance of `Command` from a list of script parts.
# 
#         :type raw_script: [basestring]
#         :rtype: Command
#         :raises: EmptyCommand
# 
#         """
#         script = format_raw_script(raw_script)
#         if not script:
#             raise EmptyCommand
# 
#         expanded = shell.from_shell(script)
#         output = get_output(script, expanded)
#         return cls(expanded, output)


# Path: tests/rules/test_remove_shell_prompt_literal.py
import pytest
from thefuck.rules.remove_shell_prompt_literal import match, get_new_command
from thefuck.types import Command



@pytest.fixture
def output():
    return "$: command not found"


@pytest.mark.parametrize(
    "script",
    [
        "$ cd newdir",
        " $ cd newdir",
        "$ $ cd newdir",
        " $ $ cd newdir",
    ],
)
def test_match(script, output):
    assert match(Command(script, output))


@pytest.mark.parametrize(
    "command",
    [
        Command("$", "$: command not found"),
        Command(" $", "$: command not found"),
        Command("$?", "127: command not found"),
        Command(" $?", "127: command not found"),

        Command("", ""),