mirror of
https://github.com/fairyglade/ly.git
synced 2026-05-06 15:20:36 +00:00
Add config validation argument (closes #969)
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
@@ -226,6 +226,12 @@ You can, of course, still select the init system of your choice when using this
|
|||||||
|
|
||||||
You can find all the configuration in `/etc/ly/config.ini`. The file is fully commented, and includes the default values.
|
You can find all the configuration in `/etc/ly/config.ini`. The file is fully commented, and includes the default values.
|
||||||
|
|
||||||
|
You may also check the validity of your configuration file (i.e. if there are any errors in it) with the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ly --validate-config /etc/ly/config.ini
|
||||||
|
```
|
||||||
|
|
||||||
## Controls
|
## Controls
|
||||||
|
|
||||||
Use the Up/Down arrow keys to change the current field, and the Left/Right arrow keys to scroll through the different fields (whether it be the info line, the desktop environment, or the username). The info line is where messages and errors are displayed.
|
Use the Up/Down arrow keys to change the current field, and the Left/Right arrow keys to scroll through the different fields (whether it be the info line, the desktop environment, or the username). The info line is where messages and errors are displayed.
|
||||||
|
|||||||
27
src/main.zig
27
src/main.zig
@@ -172,7 +172,8 @@ pub fn main(init: std.process.Init) !void {
|
|||||||
\\-h, --help Shows all commands.
|
\\-h, --help Shows all commands.
|
||||||
\\-v, --version Shows the version of Ly.
|
\\-v, --version Shows the version of Ly.
|
||||||
\\-c, --config <str> Overrides the default configuration path. Example: --config /usr/share/ly
|
\\-c, --config <str> Overrides the default configuration path. Example: --config /usr/share/ly
|
||||||
\\--use-kmscon-vt Use KMSCON instead of kernel VT
|
\\--use-kmscon-vt Uses KMSCON instead of the kernel VT.
|
||||||
|
\\--validate-config <str> Validates the given configuration file.
|
||||||
);
|
);
|
||||||
|
|
||||||
var diag = clap.Diagnostic{};
|
var diag = clap.Diagnostic{};
|
||||||
@@ -211,6 +212,30 @@ pub fn main(init: std.process.Init) !void {
|
|||||||
}
|
}
|
||||||
if (res.args.config) |path| config_parent_path = path;
|
if (res.args.config) |path| config_parent_path = path;
|
||||||
if (res.args.@"use-kmscon-vt" != 0) state.use_kmscon_vt = true;
|
if (res.args.@"use-kmscon-vt" != 0) state.use_kmscon_vt = true;
|
||||||
|
if (res.args.@"validate-config") |path| {
|
||||||
|
var parser = try IniParser(Config).init(
|
||||||
|
state.allocator,
|
||||||
|
state.io,
|
||||||
|
path,
|
||||||
|
migrator.configFieldHandler,
|
||||||
|
);
|
||||||
|
defer parser.deinit();
|
||||||
|
|
||||||
|
for (parser.errors.items) |err| {
|
||||||
|
std.log.err(
|
||||||
|
"failed to convert value '{s}' of option '{s}' to type '{s}': {s}",
|
||||||
|
.{ err.value, err.key, err.type_name, err.error_name },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parser.maybe_load_error) |err| {
|
||||||
|
std.log.err("failed to load config file: {s}", .{@errorName(err)});
|
||||||
|
std.process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
std.log.info("no errors detected!", .{});
|
||||||
|
std.process.exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load configuration file
|
// Load configuration file
|
||||||
|
|||||||
Reference in New Issue
Block a user