Skip to content

Commit

Permalink
Merge 20d044f into 7661636
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFriendlyCoder committed May 30, 2018
2 parents 7661636 + 20d044f commit 4a9710d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/friendlyshell/base_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def __init__(self, *args, **kwargs):
# only used for nested sub-shells
self._parent = None

# default comment delimiter
self.comment_delimiter = "#"


@property
def _config_folder(self):
"""Gets the folder where config and log files should be stored
Expand Down Expand Up @@ -210,6 +214,10 @@ def run(self, *_args, **kwargs):
if not line:
continue

if line.startswith(self.comment_delimiter):
self.debug("Skipping comment line %s", line)
continue

# Before we process our command input, see if we need to
# substitute any environment variables that may be used
line = os.path.expandvars(line)
Expand Down
17 changes: 17 additions & 0 deletions tests/test_base_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ def do_my_cmd(self):
obj.run(input_stream=in_stream)
assert expected_message in capsys.readouterr().out

@pytest.mark.timeout(5)
def test_simple_run_comment(capsys):
expected_message = "My output from my command"
class MyShell(BaseShell):
command_ran = False
def do_my_cmd(self):
MyShell.command_ran = True
self.info(expected_message)

obj = MyShell()
in_stream = StringIO("""#my_cmd
exit""")

obj.run(input_stream=in_stream)
assert MyShell.command_ran is False
assert expected_message not in capsys.readouterr().out

@pytest.mark.timeout(5)
def test_run_input_stream_no_exit(capsys):
expected_message = "My output from my command"
Expand Down

0 comments on commit 4a9710d

Please sign in to comment.