# Done automatically when nailing-cargo sees that the cargo
# subcommand is one which needs it, eg `fetch'.
#
+# --online | --offline
+# Whether to allow cargo to make network access.
+# (nailing-cargo always passes --offline to cargo, unless
+# --online is in force). The default is offline,
+# unless the cargo subcommand is one which implies
+# online (currently, `fetch').
+#
# Cargo.nail:
#
# # Adds each <subdir> to the list of directories whose
# or
# use = "null"
#
+# Other settings:
+# [misc]
+# online = true # forces default to be --online
+# online = false # forces default to be --offline
+#
# Limitations:
#
# Always dirties everyone's Cargo.toml, but tries to put them
our $cargo_manifest_args;
our $cargo_target_arg=1;
our $alt_cargo_lock;
+our $online;
our @configs;
our $verbose=1;
}
sub addargs () {
+ $online //= cfg_bool qw(misc online);
+
if (@ARGV>=2 &&
$ARGV[0] =~ m{\bcargo\b}) {
if ($ARGV[1] =~ m/^(?:generate-lockfile|update)$/) {
}
if ($ARGV[1] =~ m/^(?:fetch)$/) {
$cargo_target_arg=0;
+ $online //= 1;
}
}
$cargo_lock_update //= 0;
$cargo_manifest_args //=
(defined $oot_dir) && !$cargo_lock_update;
+ $online //= 0;
+
if ($cargo_manifest_args) {
push @ARGV, "--manifest-path=${src_absdir}/Cargo.toml",
qw(--locked);
}
push @ARGV, "--target=$target";
}
+
+ push @ARGV, "--offline" unless $online;
}
our $oot_absdir;
$cargo_manifest_args= !!$1;
} elsif (m{^--(no-)?cargo-target-arg}) {
$cargo_target_arg= !!$1;
+ } elsif (m{^--(on|off)line$}) {
+ $online = $1 eq 'on';
} else {
die "$self: unknown long option $_\n";
}