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.

Help text duplicated when using more than 1 CLI instance

See original GitHub issue
import sys
from cmd2 import cmd2

instance_1 = cmd2.Cmd()
instance_2 = cmd2.Cmd()
sys.exit(instance_2.cmdloop())

With this program, run alias -h. The subcommand help gets repeated.

  SUBCOMMAND
    create    create or overwrite an alias
    delete    delete aliases
    list      delete aliases
    create    create or overwrite an alias
    delete    delete aliases
    list      delete aliases

Since the parsers (e.g. Cmd.alias_parser) are class objects, they get updated with each instantiation. This problem has existed since we added the argparse decorators, but it’s being exercised a bit more since we added CommandSet and as_subcommand_to decorators. This specific issue of repeated text was introduced when cmd2.py started using the as_subcommand_to decorator.

For the 2.0 release, we need to find a way to make deep copies of the parsers and tie each copy to an instance. We won’t have 1 parser attached to the functions anymore. Instead the decorators will need to retrieve the instance-specific parser.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
kmvanbruntcommented, Jan 21, 2021

@anselor and I agree the 2.0 release does not have to wait for this fix. The risk of someone using two cmd2 objects and editing common parsers between them is pretty low.

0reactions
tleonhardtcommented, Jul 14, 2022

@kmvanbrunt Is this fixed now? Or are we waiting on some better fix?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Help text duplicated when using more than 1 CLI instance -
import sys from cmd2 import cmd2 instance_1 = cmd2.Cmd() instance_2 = cmd2.Cmd() sys.exit(instance_2.cmdloop()). With this program, run alias -h .
Read more >
Atlassian CLI 3.8.0 - Help text - Atlassian Command Line Interface ...
To get help for a specific action, type the action followed by --help - example: --action getProjectList --help · Use double dash for...
Read more >
How to use the uniq command to process lists in Linux - Red Hat
In this scenario, the uniq command helps you to print duplicate lines once in the output. It actually discards the lines which are...
Read more >
uniq Command in LINUX with examples - GeeksforGeeks
In simple words, uniq is the tool that helps to detect the adjacent duplicate lines and also deletes the duplicate lines.
Read more >
Zsh tab completion duplicating command name - Stack Overflow
This effect also could be reproduced if you use any of fancy UTF-8 characters like arrow, "git branch" character and so on.
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