Releases: ameily/pypsi
Releases · ameily/pypsi
v1.4.2
Pypsi v1.4.1
Huge shout out to @Rudedog9d for implementing several kick ass features. Pypsi 1.4.1 added automatic tab completion of argparse
objects including subparsers and an improved include
system.
Automatic tab completion
Argument flags and values can be tab completed. This allows you to do cool things like:
pypsi> macro -<tab>
-l --list -d --delete -s --show
pypsi> macro --s<tab>
pypsi> macro --show <tab>
test_macro1 test_macro2
This above is implemented with only a few lines of code in the macro command:
def __init__(self):
# .....
self.parser.add_argument(
'-s', '--show', help='print macro body',
metavar='NAME', completer=self.complete_macros
)
# ......
def complete(self, shell, args, prefix):
return command_completer(self.parser, shell, args, prefix)
def complete_macros(self, shell, args, prefix):
return list(shell.ctx.macros.keys())
This functionality is really easy to enable:
PypsiArgParser.add_argument()
now accepts an optional keyword argument,completer
, which is a callable that returns possible completions for the argument.- In your command's
complete()
method, simply returncommand_completer()
.
Have a look at the tab complete section in the docs for a brief overview and don't miss the actual command_completer() documentation.
Pypsi 1.2.3
Release containing minor bug fixes.