Default directory for storage and data-dir per command

With this PR we default to the proper OS default directory for storing application data.
Since the reset-config command does not require a data directory (and causes side effects with the default one), the data directory is not initialized per command.
This commit is contained in:
Daniel Karzel 2021-01-28 16:05:14 +11:00
parent 967736766b
commit 9be6449e49
3 changed files with 31 additions and 15 deletions

View file

@ -5,9 +5,12 @@ use uuid::Uuid;
#[derive(structopt::StructOpt, Debug)]
pub struct Options {
// TODO: Default value should points to proper configuration folder in home folder
#[structopt(long = "data-dir", default_value = "./.swap-data/")]
pub data_dir: String,
#[structopt(
long = "data-dir",
help = "Provide a custom path to the data directory.",
parse(from_os_str)
)]
pub data_dir: Option<PathBuf>,
#[structopt(subcommand)]
pub cmd: Command,
@ -80,7 +83,7 @@ pub enum Resume {
pub struct Config {
#[structopt(
long = "config",
help = "Provide a custom path to a configuration file. The configuration file must be a toml file.",
help = "Provide a custom path to the configuration file. The configuration file must be a toml file.",
parse(from_os_str)
)]
pub config_path: Option<PathBuf>,