Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

default complete function does not display descriptions #1388

Answered by kmvanbrunt
Sripadvallabh asked this question in Q&A
Discussion options

Due to some requirement, i have made a default command by overriding the default() function as shown below:

 # Default command to be 'run'
 def default(self, stmt):
 self.onecmd(f"run {stmt.raw}")

Because of this, most of the time users would be invoking 'run' command directly with arguments instead of calling 'run ':

(cmd2) <args> 
instead of 
(cmd2) run <args>

To autocomplete for the default function i have overriden the completedefault() function:

def completedefault(self, text, line, begidx, endidx):
 return run_completer(self, text, line, begidx, endidx)

run_completer() returns a list of cmd2.CompletionItem but i couldn't see the descriptions when i press double <tab>.

May i know if there is a way to make this work?

You must be logged in to vote

CompletionItem handling is only present in the argparse tab completion code.

Since default() is not an argparse-decorated command, nor can it be since it's not a do_xxx function, only basic tab completion is supported.

Replies: 2 comments 1 reply

Comment options

@kmvanbrunt This sounds up your alley if you get a chance ...

You must be logged in to vote
0 replies
Comment options

CompletionItem handling is only present in the argparse tab completion code.

Since default() is not an argparse-decorated command, nor can it be since it's not a do_xxx function, only basic tab completion is supported.

You must be logged in to vote
1 reply
Comment options

Understood. Thanks for your reply

Answer selected by Sripadvallabh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /