Skip to content
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

Model commands and options with composition #4188

Open
nwatson22 opened this issue Mar 7, 2024 · 1 comment · May be fixed by #4292
Open

Model commands and options with composition #4188

nwatson22 opened this issue Mar 7, 2024 · 1 comment · May be fixed by #4292
Assignees
Labels
enhancement pyk Issues transferred from runtimeverification/pyk

Comments

@nwatson22
Copy link
Member

nwatson22 commented Mar 7, 2024

For a follow-up refactor to runtimeverification/pyk#916

Split the class Options into Options which holds the options as fields, and OptionsHandler which takes a parameterized Options type and can export argparse information for that option, handle default values, and instantiate its Options class.
Commands would then be instantiated by passing in OptionsHandlers for the appropriate sets of options

See comment here

@ehildenb
Copy link
Member

ehildenb commented Mar 7, 2024

Maybe a nice design would be something like:

class Option:
    default: Any | None = None
    name: str
    cli: str
    help: str

    @abstractmethod
    def parser(parser: ArgumentParser) -> None:
        ...

class BoolOption(Option):
    ...

    def parser(_parser) -> None:
        _parser.add_argument(self.cli, self.name, action='store_true', default=self.default, help=self.help)
        _parser.add_argument(f`{--no-}{self.cli[3:]}', self.name, action='store_false', default=self.default, help=self.help)

Pretty rough sketch, but basically the idea is that we are only declaratively making options, and the parsers are generated for us, and then more functionality can be derived from the declarative arguments instead of speciffying thinsg like the parser/toml reader directly.

@Baltoli Baltoli added the pyk Issues transferred from runtimeverification/pyk label Apr 10, 2024
@Baltoli Baltoli transferred this issue from runtimeverification/pyk Apr 11, 2024
@nwatson22 nwatson22 linked a pull request Apr 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement pyk Issues transferred from runtimeverification/pyk
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants