diff --git a/README.md b/README.md index 01c4a09..016e9e7 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ First create a repo silo --repo /path/to/repo init ``` 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 diff --git a/src/args.rs b/src/args.rs index 011dd69..d9f4afd 100644 --- a/src/args.rs +++ b/src/args.rs @@ -7,7 +7,7 @@ pub struct Args { #[arg(short, long)] pub verbose: bool, - #[arg(short, long, default_value = ".")] + #[arg(short, long, default_value = default_repo() )] pub repo: PathBuf, /// The silo command to execute #[command(subcommand)] @@ -24,3 +24,14 @@ pub enum Command { /// Print the entire context available to templates 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 +}