-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve default argument handling (#916)
Closes runtimeverification/pyk#885. Overhauls the way command line argument parsing and parameter passing is done. When building a pyk-based command-line tool, for each subcommand of the tool, extend `class Command` . This subclass should contain all information about what arguments are accepted by that command (through providing its own arguments or inheriting from other `Options` classes), the default values of those arguments, the name of the command, and the help string for the command, as static fields. The values of those options for a specific invocation of that command are stored as non-static fields of a `Command`. The `Command` subclass contains the code that runs when that command is called in `exec()`. In addition, default values of arguments inherited from other `Options` classes can be overridden in the subclass. The `CLI` class manages the tool's CLI options. It is constructed by passing in the name of every command subclass to be included in the tool. It can then build the whole `ArgumentParser` for the tool and process the arguments to instantiate a new `*Command` of the correct type and with the correct arguments. Advantages: - All information about a subcommand is consolidated into one place - Default values specified in only one place - Commands only have to be listed once, when instantiating `CLI` - Setting up an argument parser with all subcommands is done automatically. - Routing of requested command to its associated execution function is done automatically. --------- Co-authored-by: devops <[email protected]> Co-authored-by: Tamás Tóth <[email protected]>
- Loading branch information
1 parent
bcad921
commit e200d10
Showing
9 changed files
with
883 additions
and
509 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
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 +1 @@ | ||
0.1.687 | ||
0.1.688 |
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "pyk" | ||
version = "0.1.687" | ||
version = "0.1.688" | ||
description = "" | ||
authors = [ | ||
"Runtime Verification, Inc. <[email protected]>", | ||
|
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
Oops, something went wrong.