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

Is there a way to only show base "--help" for explicitly defined options? #854

Open
aclarknexient opened this issue Aug 18, 2023 · 0 comments

Comments

@aclarknexient
Copy link

When creating the aliases, flags, etc for the options, is there a way to only show those options that I've explicitly defined?

For example, consider this code:

from traitlets import Unicode
from traitlets.config import SingletonConfigurable
from traitlets.config.application import Application


class ConfigStore(SingletonConfigurable):
    github_token = Unicode("", help="Your Github access token").tag(config=True)


class AppController(Application):
    classes = [ConfigStore]
    aliases = {
        ("github-token"): (
            "ConfigStore.github_token",
            "your github access token, usually set via environment variable GITHUB_TOKEN",
        ),
    }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)


if __name__ == "__main__":
    app = AppController()
    app.launch_instance()

When called with --help it outputs the following:

This is an application.

Options
=======
The options below are convenience aliases to configurable class-options,
as listed in the "Equivalent to" description-line of the aliases.
To see all configurable class-options for some <cmd>, use:
    <cmd> --help-all

--debug
    Set log-level to debug, for the most verbose logging.
    Equivalent to: [--Application.log_level=10]
--show-config
    Show the application's configuration (human-readable format)
    Equivalent to: [--Application.show_config=True]
--show-config-json
    Show the application's configuration (json format)
    Equivalent to: [--Application.show_config_json=True]
--github-token=<Unicode>
    your github access token, usually set via environment variable GITHUB_TOKEN
    Default: ''
    Equivalent to: [--ConfigStore.github_token]

To see all available configurables, use `--help-all`.

Is there a way to configure the Application such that it only displays this:

--github-token=<Unicode>
    your github access token, usually set via environment variable GITHUB_TOKEN
    Default: ''

Sorry to ask a question in a github issue. Is there a better forum to ask these sorts of questions? Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant