question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for partial commands

See original GitHub issue

Some shells accept and interpret partial commands and it would be a great feature to be included.

Let’s take a look an example: By default cmd2 includes quit command, which is used to end the cmd-session. In many scenarios, it would be useful to allow the user just write q to get the same functionality. Of course cmd2 support many ways of doing this, such as alias, macros or shortcuts, however, all of them should be created “manually” for each command.

Of course, there may be conflicts such not always the first letter could be used. Let’s say we have 2 different commands called stop and show (that can be found in many shells that support this kind of things). In this scenario, it would be great to automatically cmd2 allow using sh or sho as an alias of the command show, in the same way as st or sto as alias of stop. Of course s have 2 possible candidates, so it may be considered just an invalid/incomplete command.

A possible implementation: One possible implementation that may even work with subcommands is simple: 1 - the user input a command 2.1 - If the command exists or is an alias execute it as always 2.2 - if the commands does not exists, call autocomplete 3.1 - if the autocomplete returns none or more than 1 results, return invalid command as always 3.2 - if the autocomplete returns exactly one result, try to run that one and store it as if the user has written it down.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
anselorcommented, Sep 3, 2020

I’ve never actually used it but I know we have this plugin for abbreviated command support. It seems very similar to what you’re describing.

https://github.com/python-cmd2/cmd2-abbrev

0reactions
ralequicommented, Nov 22, 2020

Thank you @kmvanbrunt . I’ll probably reopen this issue when I have time to work on it. I still did not forget about it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PARTIAL command - UNICOM Systems, Inc. Support
The PARTIAL command enables you to keep the hierarchy of data that has met all of the selection criteria up to a given...
Read more >
universal help/man command: help builtin partial matches
Since help is the only one of the commands that works with partial matches, you can just invert the order of the commands:...
Read more >
Partial command list by function - BMC Documentation
Partial command list by function. In the Commands panel, you can type S in front of INTERVAL, SYSTEM, GROUPS, FILTER, and OUTPUT to...
Read more >
Tclsh can support user only type partial tcl command, but Tcl ...
Partial command cannot be recognized when source run.tcl script. a) run.tcl. setup_design my_prove my_pro. b) source the script run.tcl.
Read more >
Possible to use an alias to print a partial command after the ...
Note double semicolon to terminate each option. “2”) echo msg "Kernels currently installed on this machine: " echo mhwd-kernel -li echo # ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found