Skip to content

Pattern-based commands and specific actions for empty commands #1246

Answered by anselor
blairfrandeen asked this question in Q&A
Discussion options

You must be logged in to vote

This behavior is very different from how most of cmd behaves. There are 2 avenues you could explore, though.

In the Cmd class, all commands eventually hit the onecmd() function where it attempts to locate the do_ function that corresponds to a command. If it can't find a command, it calls the default() function. You could try overriding default() and, failing that, try overriding onecmd(). If you have custom state tracking, you can probably use as the basis for determining which of your functions you want to call.

Completion starts by calling the Cmd.complete() function which then looks up the command function and determines the type of completion depending on the specifics of the command…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by blairfrandeen
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants