Rename the global --force flag to --overwrite.

- This flag now only controls whether existing files are
    overwritten.

  - Fixes #31.
This commit is contained in:
Justus Winter 2024-10-02 18:42:31 +02:00
parent 80d51a9a87
commit dff6664f47
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386
9 changed files with 15 additions and 13 deletions

2
NEWS
View File

@ -30,6 +30,8 @@
`--recreate` that forces a signature to be created even if it
should not be necessary because the parameters did not change.
Previously, the global `--force` was used for this.
- The global `--force` flag has been renamed to `--overwrite` and
now controls whether existing files are overwritten.
* Changes in 0.38.0
** Notable changes
- New subcommand `sq key subkey delete` to delete secret key

View File

@ -226,12 +226,12 @@ to refer to OpenPGP keys that do contain secrets.
)]
pub struct SqCommand {
#[clap(
long = "force",
long = "overwrite",
global = true,
help_heading = GLOBAL_OPTIONS_HEADER,
help = "Overwrite existing files",
)]
pub force: bool,
pub overwrite: bool,
#[clap(
long,
env = "SEQUOIA_HOME",

View File

@ -86,7 +86,7 @@ impl FileOrStdout {
fn _create_sink(&self, sq: &Sq) -> Result<Box<dyn Write + Sync + Send>>
{
if let Some(path) = self.path() {
if !path.exists() || sq.force {
if !path.exists() || sq.overwrite {
Ok(Box::new(
OpenOptions::new()
.write(true)
@ -97,7 +97,7 @@ impl FileOrStdout {
))
} else {
Err(anyhow::anyhow!(
"File {} exists, use \"sq --force ...\" to overwrite",
"File {} exists, use \"sq --overwrite ...\" to overwrite",
path.display(),
))
}

View File

@ -283,8 +283,6 @@ fn main() -> Result<()> {
.collect::<Vec<&str>>();
policy.good_critical_notations(&known_notations);
let force = c.force;
let mut password_cache = Vec::new();
for password_file in &c.password_file {
let password = std::fs::read(&password_file)
@ -297,7 +295,7 @@ fn main() -> Result<()> {
let sq = Sq {
verbose: c.verbose,
quiet: c.quiet,
force,
overwrite: c.overwrite,
batch: c.batch,
policy: &policy,
time,

View File

@ -87,7 +87,9 @@ pub struct Sq<'store, 'rstore>
{
pub verbose: bool,
pub quiet: bool,
pub force: bool,
/// Overwrite existing files.
pub overwrite: bool,
/// Prevent any kind of interactive prompting.
pub batch: bool,

View File

@ -1245,7 +1245,7 @@ impl Sq {
cmd.arg(&cert).arg(userid);
if let Some(output_file) = output_file {
cmd.arg("--force").arg("--output").arg(output_file);
cmd.arg("--overwrite").arg("--output").arg(output_file);
}
let output = self.run(cmd, Some(success));

View File

@ -35,7 +35,7 @@ fn sq_key_expire() -> Result<()> {
cmd.args(["--cert", &fpr ]);
} else {
cmd
.arg("--force")
.arg("--overwrite")
.arg("--cert-file").arg(&cert_path)
.arg("--output").arg(&updated_path);
}

View File

@ -51,7 +51,7 @@ fn sq_key_subkey() -> Result<()> {
]);
} else {
cmd.args([
"--force",
"--overwrite",
"--output",
&modified_cert_path.to_string_lossy(),
"--cert-file", &cert_path.to_string_lossy(),

View File

@ -53,7 +53,7 @@ fn sq_key_subkey_expire() -> Result<()> {
cmd.args(["--cert", &fpr ]);
} else {
cmd
.arg("--force")
.arg("--overwrite")
.arg("--cert-file").arg(&cert_path)
.arg("--output").arg(&updated_path);
}
@ -114,7 +114,7 @@ fn sq_key_subkey_expire() -> Result<()> {
cmd.args([ "--cert", &fpr ]);
} else {
cmd
.arg("--force")
.arg("--overwrite")
.arg("--cert-file").arg(&updated_path)
.arg("--output").arg(&updated2_path);
}