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

Configuration system #4

Closed
doublevcodes opened this issue Jan 31, 2022 · 5 comments
Closed

Configuration system #4

doublevcodes opened this issue Jan 31, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@doublevcodes
Copy link
Owner

The user needs to be able to set options within a sirius.config.toml file. This will be implemented using tomli

@Shivansh-007
Copy link
Collaborator

I would like to work on this, it would be based on the work done by arl on discord-modmail/modmail#75, where one could write configuration classes using marshmallow and attrs. This would support auto-generation of docs in the config file.

Example:

@attr.s(auto_attribs=True, slots=True)
class TwitterAuthCfg:
    """Twitter account authentication configuration."""

    api_key: str = attr.ib(
        default="",
        on_setattr=attr.setters.frozen,
        repr=False,
        metadata={
            "required": True,
            "allow_none": False,
            METADATA_TABLE: ConfigMetadata(
                description="Think of this as the user name that represents your account when using the app.",
            ),
        },
    )
    api_secret: str = attr.ib(
        default="",
        on_setattr=attr.setters.frozen,
        repr=False,
        metadata={
            "required": True,
            "allow_none": False,
            METADATA_TABLE: ConfigMetadata(
                description="Think of this as the password that represents your account when using the app.",
            ),
        },
    )

Would auto-generate:

[auth]
# Think of this as the user name that represents your account when using the app.
api_key = ""
# Think of this as the password that represents your account when using the app.
api_secret = ""

@doublevcodes doublevcodes added the enhancement New feature or request label Feb 2, 2022
@doublevcodes
Copy link
Owner Author

So how would this work, a default configuration is generated with lots of empty keys? I'd prefer that the configuration file only contain keys that need to be used.

@Shivansh-007
Copy link
Collaborator

So how would this work, a default configuration is generated with lots of empty keys? I'd prefer that the configuration file only contain keys that need to be used.

Yes, it would only include the config keys which are required, and possibly I could add a separate flag if the user wants to generate with "all" of the keys.

@doublevcodes
Copy link
Owner Author

So how would this work, a default configuration is generated with lots of empty keys? I'd prefer that the configuration file only contain keys that need to be used.

Yes, it would only include the config keys which are required, and possibly I could add a separate flag if the user wants to generate with "all" of the keys.

That sounds good.

So:

  • Configuration powered by marshmallow and attrs
  • A new CLI command to bootstrap a project with an initial configuration

@Shivansh-007
Copy link
Collaborator

Should be closed by #6

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

No branches or pull requests

2 participants