Autodocument vars/features #15

Open
opened 2023-05-18 22:51:57 -04:00 by MatthewCroughan · 2 comments
MatthewCroughan commented 2023-05-18 22:51:57 -04:00 (Migrated from github.com)

When making additional envvars that control the program/code flow like cac2be7a4f it is important to consider that it is not automatically documenting itself or making itself known in anyway.

It might be possible to make a rust function that mandates a documentation string, and that could be printed in some way by the program, imagine stardust-xr-server --list-vars. The way --list-vars could be populated is by a function like stardustxr_make_feature which would take a documentation string and env var as arguments, therefore making it impossible to make an envvar lookup that doesn't document itself and make itself known within the code.

When making additional envvars that control the program/code flow like https://github.com/StardustXR/server/commit/cac2be7a4fb4f1eea187322dc3aad291007e72bc it is important to consider that it is not automatically documenting itself or making itself known in anyway. It might be possible to make a rust function that mandates a documentation string, and that could be printed in some way by the program, imagine `stardust-xr-server --list-vars`. The way `--list-vars` could be populated is by a function like `stardustxr_make_feature` which would take a documentation string and env var as arguments, therefore making it impossible to make an envvar lookup that doesn't document itself and make itself known within the code.
Sntx626 commented 2024-03-04 09:20:45 -05:00 (Migrated from github.com)

Should a config struct be introduced that is build from cli args, env vars and config files to solve this?
This struct could easily be (self-) documented and extended. It would also encapsulate all configuration.

Should a `config` struct be introduced that is build from `cli args`, `env vars` and `config files` to solve this? This struct could easily be (self-) documented and extended. It would also encapsulate all configuration.
Sntx626 commented 2024-03-04 15:51:29 -05:00 (Migrated from github.com)

There are already proven crates that we could use to achive this, i.e. config and figment.

If there's interest for something like it, I'd be willing to implement a draft PR with this feature.

There are already proven crates that we could use to achive this, i.e. [config](https://crates.io/crates/config) and [figment](https://crates.io/crates/figment). If there's interest for something like it, I'd be willing to implement a draft PR with this feature.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: StardustXR/server#15