Skip to content

Commit

Permalink
directvt#571 WIP: Append the specified fragment instead of replacing …
Browse files Browse the repository at this point in the history
…the configuration (-c <fragment/>)
  • Loading branch information
o-sdn-o committed Sep 12, 2024
1 parent 31f33f8 commit fb92f92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion doc/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ graph LR
- Hardcoded settings
- See [/src/vtm.xml](../src/vtm.xml) for reference.
- `--config <file>` CLI option
- Instead of the path to the configuration file, the configuration body itself can be specified (this case is detected by the keyword `<config` at the beginning).
- The current configuration can be patched by specifying a configuration fragment in plain text in place of the configuration file path (this case is detected by the `<config` keyword at the beginning).
`command line`:
```bash
vtm -c "<config><term><scrollback size=1000000 growstep=100000/></term></config>" -r term
Expand Down
18 changes: 9 additions & 9 deletions src/netxs/desktopio/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,7 @@ namespace netxs::app::shared
auto load = [&](qiew shadow)
{
if (shadow.empty()) return faux;
if (utf::dequote(shadow).starts_with("<config")) // The configuration text data is specified directly instead of the path to the configuration file.
{
auto utf8 = utf::dequote(shadow);
log("%%Use directly specified settings:\n%body%", prompt::apps, ansi::hi(utf8));
conf.fuse<Print>(utf8);
return true;
}
else if (shadow.starts_with(":")) // Receive configuration via memory mapping.
if (shadow.starts_with(":")) // Receive configuration via memory mapping.
{
shadow.remove_prefix(1);
auto utf8 = os::process::memory::get(shadow);
Expand Down Expand Up @@ -521,12 +514,19 @@ namespace netxs::app::shared
log(prompt::pads, "Not found");
return faux;
};
if (!load(cli_config_path)) // Merge explicitly specified settings.
auto frag = utf::dequote(cli_config_path);
if (!frag.starts_with("<config")) frag = {}; // The configuration fragment could be specified directly in place of the configuration file path.
if (frag || !load(cli_config_path)) // Merge explicitly specified settings.
{
load(app::shared::sys_config); // Merge system-wide settings.
load(app::shared::usr_config); // Merge user-wise settings.
}
conf.fuse<Print>(patch); // Apply dtvt patch.
if (frag)
{
log("%%Apply the specified configuration fragment:\n%body%", prompt::apps, ansi::hi(frag));
conf.fuse<Print>(frag);
}
return conf;
}
}
Expand Down

0 comments on commit fb92f92

Please sign in to comment.