Skip to content
Snippets Groups Projects
Commit d1adcde1 authored by Yorhel's avatar Yorhel
Browse files

Add --ignore-config command line option

parent 39a137c1
No related branches found
No related tags found
No related merge requests found
......@@ -73,6 +73,10 @@ information.
This enables viewing and sorting by the latest child mtime, or modified time,
using 'm' and 'M', respectively.
=item --ignore-config
Do not attempt to load any configuration files.
=back
=head2 Scan Options
......@@ -272,7 +276,8 @@ Ncdu can be configured by placing command-line options in C</etc/ncdu.conf> or
C<$HOME/.config/ncdu/config>. If both files exist, the system configuration
will be loaded before the user configuration, allowing users to override
options set in the system configuration. Options given on the command line will
override options set in the configuration files.
override options set in the configuration files. The files will not be read at
all when C<--ignore-config> is given on the command line.
The configuration file format is simply one command line option per line. Lines
starting with C<#> are ignored. Example configuration file:
......
......@@ -306,6 +306,7 @@ fn help() noreturn {
\\ --exclude-kernfs Exclude Linux pseudo filesystems (procfs,sysfs,cgroup,...)
\\ --confirm-quit Confirm quitting ncdu
\\ --color SCHEME Set color scheme (off/dark/dark-bg)
\\ --ignore-config Don't load config files
\\
\\Refer to `man ncdu` for the full list of options.
\\
......@@ -394,6 +395,15 @@ pub fn main() void {
}
if (std.os.getenvZ("NO_COLOR") == null) config.ui_color = .darkbg;
const loadConf = blk: {
var args = std.process.ArgIteratorPosix.init();
while (args.next()) |a|
if (std.mem.eql(u8, a, "--ignore-config"))
break :blk false;
break :blk true;
};
if (loadConf) {
tryReadArgsFile("/etc/ncdu.conf");
if (std.os.getenvZ("XDG_CONFIG_HOME")) |p| {
......@@ -405,6 +415,7 @@ pub fn main() void {
defer allocator.free(path);
tryReadArgsFile(path);
}
}
var scan_dir: ?[]const u8 = null;
var import_file: ?[:0]const u8 = null;
......@@ -427,6 +438,7 @@ pub fn main() void {
else if (opt.is("-o")) export_file = allocator.dupeZ(u8, args.arg()) catch unreachable
else if (opt.is("-f") and import_file != null) ui.die("The -f flag can only be given once.\n", .{})
else if (opt.is("-f")) import_file = allocator.dupeZ(u8, args.arg()) catch unreachable
else if (opt.is("--ignore-config")) {}
else if (argConfig(&args, opt)) {}
else ui.die("Unrecognized option '{s}'.\n", .{opt.val});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment