axconfig-gen
A TOML-based configuration generation tool for ArceOS.
Executable Usage
Usage: axconfig-gen [OPTIONS] <SPEC>...
Arguments:
<SPEC>... Paths to the config specification files
Options:
-c, --oldconfig <OLDCONFIG> Path to the old config file
-o, --output <OUTPUT> Path to the output config file
-f, --fmt <FMT> The output format [default: toml] [possible values: toml, rust]
-r, --read <RD_CONFIG> Getting a config item with format `table.key`
-w, --write <WR_CONFIG> Setting a config item with format `table.key=value`
-v, --verbose Verbose mode
-h, --help Print help
-V, --version Print version
For example, to generate a config file .axconfig.toml from the config specifications distributed in a.toml and b.toml, you can run:
$ axconfig-gen a.toml b.toml -o .axconfig.toml -f toml
See defconfig.toml for an example of a config specification file.
Value types are necessary for generating Rust constant definitions. Types can be specified by the comment following the config item. Currently supported types are bool, int, uint, str, (type1, type2, ...) for tuples, and [type] for arrays. If no type is specified, it will try to infer the type from the value.
Library Usage
use ;
let config_toml = r#"
are-you-ok = true
one-two-three = 123
[hello]
"one-two-three" = "456" # int
array = [1, 2, 3] # [uint]
tuple = [1, "abc", 3]
"#;
let config = from_toml.unwrap;
let rust_code = config.dump.unwrap;
assert_eq!;
Related libraries
There is also a procedural macro library axconfig-macros that can be
used to include TOML files in your project and convert them to Rust code at
compile time.