Add default repo path to data dir

main
trivernis 10 months ago
parent 407561cd38
commit 0d51537b98
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -16,6 +16,7 @@ First create a repo
silo --repo /path/to/repo init silo --repo /path/to/repo init
``` ```
This creates the repo directory and initializes a git repository. This creates the repo directory and initializes a git repository.
If no `--repo` argument is passed, it will default to `$HOME/.local/share/silo` or `$HOME/AppData/Roaming/silo`.
### Add configuration files ### Add configuration files

@ -7,7 +7,7 @@ pub struct Args {
#[arg(short, long)] #[arg(short, long)]
pub verbose: bool, pub verbose: bool,
#[arg(short, long, default_value = ".")] #[arg(short, long, default_value = default_repo() )]
pub repo: PathBuf, pub repo: PathBuf,
/// The silo command to execute /// The silo command to execute
#[command(subcommand)] #[command(subcommand)]
@ -24,3 +24,14 @@ pub enum Command {
/// Print the entire context available to templates /// Print the entire context available to templates
Context, Context,
} }
fn default_repo() -> &'static str {
lazy_static::lazy_static! {
static ref DEFAULT_REPO: String = dirs::data_dir()
.unwrap()
.join("silo")
.to_string_lossy()
.into();
}
&*DEFAULT_REPO
}

Loading…
Cancel
Save