-
Notifications
You must be signed in to change notification settings - Fork 127
Modular commands attempt 3 #943 #961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c9a8f49 to
a92faa5
Compare
Codecov Report
@@ Coverage Diff @@
## master #961 +/- ##
==========================================
+ Coverage 97.74% 97.83% +0.09%
==========================================
Files 21 22 +1
Lines 4217 4487 +270
==========================================
+ Hits 4122 4390 +268
- Misses 95 97 +2
Continue to review full report at Codecov.
|
6fdd73a to
6837065
Compare
| terminators: Optional[List[str]] = None, shortcuts: Optional[Dict[str, str]] = None) -> None: | ||
| terminators: Optional[List[str]] = None, shortcuts: Optional[Dict[str, str]] = None, | ||
| command_sets: Optional[Iterable[CommandSet]] = None, | ||
| auto_load_commands: bool = True) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want this set to True? Won't that needlessly run _autoload_commands() for a lot of projects which don't need to call it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do because, for projects that choose to use CommandSets they will 'just work'. The search for child classes is fast because it's asking Python for child classes that have already been loaded. This should just be a lookup of information that's already loaded in memory.
21397c8 to
4cb15ee
Compare
tleonhardt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to update CHANGELOG before merging in
Issue #943 New class CommandSet can be used to tag a class as a command class. If the constructor is simple, the object will automatically be instantiated and loaded. New register_command decorator to tag any arbitrary function as a command.
…tation for CommandSet commands. Issue #943
…oad. Added unit tests. Moved installing commands into separate functions that can be called Issue #943
…ding command functions Adds handling of some edge cases. More thorough test coverage.
register arbitrary functions as commands. Added example that demonstrates use of each of the command decorators with CommandSets. Adds unit test that verifies that CommandSets containing decorators load and process commands correctly. Updated the constructor declaration for Cmd2ArgumentParser to explicitly re-declare argparse constructor parameters.
Added additional documentation
load/unload. Updated examples and documentation to include discussion of injectable sub-commands.
sub-commande => subcommand Added help/aliases to `as_subcommand_to` decorator.
Change setup.cfg so that pytest only runs tests in the tests directory by default. Attempting to run tests in the isolated_tests directory was causing a crash
…t "inv pytest" doesn't crash
ac32fad to
b5237ed
Compare
through to the ArgparseCompleter if one is registered. For subcommands, the registered argparse instance for the subcommand is now tagged with the CommandSet from which it originated. If a CommandSet is detected, it's now passed in as 'self' for the completion functions. Fixes some issue found with removing a subcommand. Adds additional tests. Added a check to prevent removal of a CommandSet if it has commands with sub-commands from another CommandSet bound to it. Documentation improvements. Standardized around using CommandSetRegistrationException during commandset install/uninstall related errors. Added support for nested sub-command injection.
b5237ed to
4fd7aa7
Compare
4fd7aa7 to
c0ad7ba
Compare
…efore passing to command handlers to access sub-command handlers
9783e95 to
b932ad4
Compare
ok, this should be the real one we want.
Going back to being integrated into the cmd2 core instead of a plugin.
Removed support for arbitrary functions as loadable modular commands. Modular commands must be in a CommandSet.
Added additional documentation and examples.
Closes #943