mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
docs and tests
This commit is contained in:
parent
7ca4fbd085
commit
8db169ec1a
2 changed files with 41 additions and 1 deletions
|
@ -1202,7 +1202,7 @@ may have one of the following signatures:
|
|||
return 0
|
||||
|
||||
def mycmd5(args, stdin=None, stdout=None, stderr=None, spec=None):
|
||||
"""Lastly, the final form of subprocess callables takes all of the
|
||||
"""This form of subprocess callables takes all of the
|
||||
arguments shown above as well as a subprocess specification
|
||||
SubprocSpec object. This holds many attributes that dictate how
|
||||
the command is being run. For instance this can be useful for
|
||||
|
@ -1218,6 +1218,24 @@ may have one of the following signatures:
|
|||
print('Hi Mom!', end=end)
|
||||
return 0
|
||||
|
||||
def mycmd6(args, stdin=None, stdout=None, stderr=None, spec=None, stack=None):
|
||||
"""Lastly, the final form of subprocess callables takes a stack argument
|
||||
in addition to the arguments shown above. The stack is a list of
|
||||
FrameInfo namedtuple objects, as described in the standard library
|
||||
inspect module. The stack is computed such the the call site is the
|
||||
first and innermost entry, while the outer frame is the last entry.
|
||||
|
||||
The stack is only computed if the alias has a "stack" argument.
|
||||
However, the stack is also accessible as "spec.stack".
|
||||
"""
|
||||
for frame_info in stack:
|
||||
frame = frame_info[0]
|
||||
print('In function ' + frame_info[3])
|
||||
print(' locals', frame.f_locals)
|
||||
print(' globals', frame.f_globals)
|
||||
print('\n')
|
||||
return 0
|
||||
|
||||
|
||||
Adding, Modifying, and Removing Aliases
|
||||
---------------------------------------
|
||||
|
|
|
@ -240,6 +240,28 @@ echo @$(which ls)
|
|||
echo Just the place for a snark. >tttt
|
||||
cat tttt
|
||||
""", 'Just the place for a snark.\n', 0),
|
||||
#
|
||||
# Test completion registration and subproc stack
|
||||
#
|
||||
("""
|
||||
def _f():
|
||||
def j():
|
||||
pass
|
||||
|
||||
global aliases
|
||||
aliases['j'] = j
|
||||
|
||||
def completions(pref, *args):
|
||||
return set(['hello', 'world'])
|
||||
|
||||
completer add j completions "start"
|
||||
|
||||
|
||||
_f()
|
||||
del _f
|
||||
|
||||
"""
|
||||
, '', 0),
|
||||
]
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue