Skip to content

Commit 957137a

Browse files
committed
Default cmd_echo to True in PyscriptBridge so things like 'py app.help()' will show output
1 parent 1c0616a commit 957137a

19 files changed

+5
-23
lines changed

cmd2/pyscript_bridge.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class PyscriptBridge(object):
247247
def __init__(self, cmd2_app):
248248
self._cmd2_app = cmd2_app
249249
self._last_result = None
250-
self.cmd_echo = False
250+
self.cmd_echo = True
251251

252252
def __getattr__(self, item: str):
253253
"""
@@ -271,10 +271,10 @@ def wrap_func(args=''):
271271
raise AttributeError("'{}' object has no attribute '{}'".format(self._cmd2_app.pyscript_name, item))
272272

273273
def __dir__(self):
274-
"""Return a custom set of attribute names to match the available commands"""
275-
commands = list(self._cmd2_app.get_all_commands())
276-
commands.insert(0, 'cmd_echo')
277-
return commands
274+
"""Return a custom set of attribute names"""
275+
attributes = self._cmd2_app.get_all_commands()
276+
attributes.insert(0, 'cmd_echo')
277+
return attributes
278278

279279
def __call__(self, args: str, echo: Optional[bool]=None) -> CommandResult:
280280
"""

tests/pyscript/bar1.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
app.cmd_echo = True
21
app.bar('11', '22')

tests/pyscript/custom_echo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
custom.cmd_echo = True
21
custom.echo('blah!')

tests/pyscript/foo1.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
app.cmd_echo = True
21
app.foo('aaa', 'bbb', counter=3, trueval=True, constval=True)

tests/pyscript/foo2.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
app.cmd_echo = True
21
app.foo('11', '22', '33', '44', counter=3, trueval=True, constval=True)

tests/pyscript/foo3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
app.cmd_echo = True
21
app.foo('11', '22', '33', '44', '55', '66', counter=3, trueval=False, constval=False)

tests/pyscript/foo4.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
app.cmd_echo = True
21
result = app.foo('aaa', 'bbb', counter=3)
32
out_text = 'Fail'
43
if result:

tests/pyscript/help.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
app.cmd_echo = True
21
app.help()

tests/pyscript/help_media.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
app.cmd_echo = True
21
app.help('media')
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
app.cmd_echo = True
21
app.media.movies.add('My Movie', 'PG-13', director=('George Lucas', 'J. J. Abrams'))

0 commit comments

Comments
 (0)