Re-initialize the database and don't overwrite it by default.

pull/29/head
Sebastian Thiel 2 years ago
parent 9120abbafb
commit f09a363119
No known key found for this signature in database
GPG Key ID: 9CB5EE7895E8268B

@ -5,7 +5,7 @@ edition = "2021"
description = "Interface with the Postsack mail processing engine from the command-line."
[[bin]]
name = "postsack"
name = "postsack-man"
path = "src/main.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

@ -1,3 +1,11 @@
# Postsack CLI
A minimial command-line interface for the `postsack` engine, allowing non-gui access to functionality.
Use the `postsack-man` (meaning _postsack-manager_) like this…
```
postsack-man
```
… to receive help on which functionality is available.

@ -21,10 +21,13 @@ mod options {
Import {
/// The path to which to write the database containing all imported data.
///
/// Note that it will be overwritten unconditionally.
/// Note that we won't refuse an existing database unless --overwrite-database is specified.
#[clap(short = 's', long, default_value = "./postsack.sqlite")]
database: PathBuf,
#[clap(short = 'f', long)]
overwrite_database: bool,
/// Emails to be considered your own emails for filtering by Sender.
#[clap(
short = 'e',
@ -67,6 +70,7 @@ fn main() -> eyre::Result<()> {
match args.cmds {
SubCommands::Import {
database,
overwrite_database,
sender_email,
email_format,
emails_folder,
@ -75,6 +79,13 @@ fn main() -> eyre::Result<()> {
if !emails_folder.is_dir() {
eyre::bail!("The mails directory at '{}' isn't accessible", emails_folder.display())
}
if overwrite_database {
std::fs::remove_file(&database).ok();
} else {
eyre::bail!("Refusing to overwrite existing database at '{}'", database.display());
}
let config = ps_core::Config::new(
Some(database.clone()),
emails_folder,

Loading…
Cancel
Save