Add --data-dir command line option
This commit is contained in:
parent
227a5a67b1
commit
40674f5071
1 changed files with 12 additions and 3 deletions
15
src/main.rs
15
src/main.rs
|
|
@ -43,6 +43,9 @@ impl Default for Command {
|
||||||
|
|
||||||
#[derive(Debug, clap::Parser)]
|
#[derive(Debug, clap::Parser)]
|
||||||
struct Args {
|
struct Args {
|
||||||
|
/// Path to a directory for cove to store its data in.
|
||||||
|
#[clap(long, short)]
|
||||||
|
data_dir: Option<PathBuf>,
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
command: Option<Command>,
|
command: Option<Command>,
|
||||||
}
|
}
|
||||||
|
|
@ -51,10 +54,16 @@ struct Args {
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
let dirs = ProjectDirs::from("de", "plugh", "cove").expect("unable to determine directories");
|
let data_dir = if let Some(data_dir) = args.data_dir {
|
||||||
println!("Data dir: {}", dirs.data_dir().to_string_lossy());
|
data_dir
|
||||||
|
} else {
|
||||||
|
let dirs =
|
||||||
|
ProjectDirs::from("de", "plugh", "cove").expect("unable to determine directories");
|
||||||
|
dirs.data_dir().to_path_buf()
|
||||||
|
};
|
||||||
|
println!("Data dir: {}", data_dir.to_string_lossy());
|
||||||
|
|
||||||
let vault = vault::launch(&dirs.data_dir().join("vault.db"))?;
|
let vault = vault::launch(&data_dir.join("vault.db"))?;
|
||||||
|
|
||||||
match args.command.unwrap_or_default() {
|
match args.command.unwrap_or_default() {
|
||||||
Command::Run => run(&vault).await?,
|
Command::Run => run(&vault).await?,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue