Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed completion argparse to allow control of the depth variable. issue #266 #267

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions fire/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import six


def Script(name, component, default_options=None, shell='bash'):
def Script(name, component, shell='bash', depth=3, default_options=None):
if shell == 'fish':
return _FishScript(name, _Commands(component), default_options)
return _BashScript(name, _Commands(component), default_options)
return _FishScript(name, _Commands(component, int(depth)), default_options)
return _BashScript(name, _Commands(component, int(depth)), default_options)


def _BashScript(name, commands, default_options=None):
Expand Down
6 changes: 3 additions & 3 deletions fire/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ def Display(lines, out):
console_io.More(text, out=out)


def CompletionScript(name, component, shell):
def CompletionScript(name, component, *args):
"""Returns the text of the completion script for a Fire CLI."""
return completion.Script(name, component, shell=shell)
return completion.Script(name, component, *args)


class FireError(Exception):
Expand Down Expand Up @@ -591,7 +591,7 @@ def _Fire(component, args, parsed_flag_args, context, name=None):
if show_completion is not None:
if name is None:
raise ValueError('Cannot make completion script without command name')
script = CompletionScript(name, initial_component, shell=show_completion)
script = CompletionScript(name, initial_component, *show_completion)
component_trace.AddCompletionScript(script)

if interactive:
Expand Down
2 changes: 1 addition & 1 deletion fire/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def CreateParser():
parser.add_argument('--verbose', '-v', action='store_true')
parser.add_argument('--interactive', '-i', action='store_true')
parser.add_argument('--separator', default='-')
parser.add_argument('--completion', nargs='?', const='bash', type=str)
parser.add_argument('--completion', nargs='*')
parser.add_argument('--help', '-h', action='store_true')
parser.add_argument('--trace', '-t', action='store_true')
# TODO(dbieber): Consider allowing name to be passed as an argument.
Expand Down