From 06077b9b33f102ee6767ee9560b111cfb3bf05bd Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 21 Jun 2020 20:28:04 +0100 Subject: [PATCH] misc.online: Support for `auto` Signed-off-by: Ian Jackson --- README.md | 15 ++++++++++----- nailing-cargo | 18 +++++++++++++++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c108724..c4b4147 100644 --- a/README.md +++ b/README.md @@ -516,11 +516,16 @@ other names are not looked up in this alias map. `[misc]`: Miscellaneous individual nailing-cargo config ------------------------------------------------------- - * `online`: boolean, specifying whether to - pass `--offline` to cargo (cargo's default is online mode). The - default is offline, unless nailing-cargo can see that the cargo - subcommand being invoked is one which requires online access, in - which case the default is online. + * `online`: + + Specifies whether to allow or prevent cargo from accessing the + network. Value is a boolean or `'auto'`. `'auto'` permits online + access if the cargo subcommand being invoked is one whose main + purpose involves online access. + + Implemented by passing `--offline` to cargo when necessary --- + cargo's default is online. nailing-cargo's default is + `'auto'`. Limitations and bugs ==================== diff --git a/nailing-cargo b/nailing-cargo index 9b7be11..b842834 100755 --- a/nailing-cargo +++ b/nailing-cargo @@ -363,7 +363,23 @@ sub calculate () { sub addargs () { $online = 1 if subcmd_p('online'); - $online //= cfg_bool qw(misc online); + if (!defined $online) { + $_ = cfg_uc qw(misc online); + if (!defined $_) { + } elsif (Types::Serialiser::is_bool $_) { + $online = $_; + } elsif (ref $_) { + } elsif (m/^a/) { + $online = undef; + } elsif (m/^[1ty]/) { # allow booleanish strings + $online = 1; # for less user frustration + } elsif (m/^[0fn]/) { + $online = 0; + } else { + badcfg qw(misc online), "expected boolean or 'auto', found '$_'"; + } + } + $online //= cfg_bool $online //= 0; $cargo_lock_update //= subcmd_p('lock-update'); -- 2.30.2