-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put a nail in aliases / Move contrib.help to own file.
Aliases were never properly conceived.
- Loading branch information
Showing
6 changed files
with
44 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from .syscomplete import * | ||
from .interactive import * | ||
from .ini import * | ||
from .alias import * | ||
from .tree import * | ||
from .commands import * | ||
from .help import * |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Alternate form of getting help. | ||
""" | ||
|
||
from .. import command | ||
|
||
|
||
class Help(command.Command): | ||
""" Show help for a command. """ | ||
|
||
name = 'help' | ||
use_pager = True | ||
|
||
def setup_args(self, parser): | ||
self.add_argument('command', nargs='?', complete=self.command_choices, | ||
help='Command name to show help for.') | ||
|
||
def command_choices(self, prefix, args): | ||
return frozenset(x for x in self.parent.subcommands | ||
if x.startswith(prefix)) | ||
|
||
def run(self, args): | ||
if not args.command: | ||
self.print_overview() | ||
else: | ||
try: | ||
command = self.parent.subcommands[args.command] | ||
except KeyError: | ||
raise SystemExit("Invalid command") | ||
command.argparser.print_help() | ||
|
||
def print_overview(self): | ||
ap = self.find_root().argparser | ||
formatter = ap._get_formatter() | ||
formatter.add_text(ap.description) | ||
for x in ap._action_groups: | ||
if x.title == 'subcommands': | ||
formatter.start_section(x.title) | ||
formatter.add_text(x.description) | ||
formatter.add_arguments(x._group_actions) | ||
formatter.end_section() | ||
break | ||
print(formatter.format_help()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters