EnergySystemsModellingLab / EnergySystemsModellingLab/MUSE2

Refactor to allow overriding `settings.toml` options directly from CLI

Open
#1,284 0 comments 0 reactions 1 assignee Claimed by @alexdewar View on GitHub
Dominant language
Rust
Stars
8
Forks
5
Avg merge
1d 2m
Merged PRs (30d)
37

Description

There are a couple of program options (viz. `overwrite` and `debug_model`) which can be set either in `settings.toml` or with command-line arguments with the latter taking precedence. With the way it's currently implemented, you need to update both the code in two places to add an option like this, which is annoying and bugprone (it would be easy to get the "CLI setting takes precedence" code wrong). It would be nice if we could just set them in one place.

The first thing that comes to mind is that we could just have a single struct representing these options. Both the `clap` crate (which we use for the CLI) and `serde` (reading TOML files) provide options for "flattening" structs that are members of other structs, so maybe we can do something this way? This will still involve figuring out how to combine the CLI options with the ones in `settings.toml` though. Dunno. Maybe worth trying!

We could use proc macros for this too, but that will probably be a pain.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.