The dotfiles manager.
feat: named installs
5 files changed, +16 -8
+1-1Cargo.lock
| @@ -242,7 +242,7 @@ dependencies = [ | ||
| 242 | 242 | |
| 243 | 243 | [[package]] |
| 244 | 244 | name = "dothub" |
| 245 | -version = "0.1.0" | |
| 245 | +version = "0.1.1" | |
| 246 | 246 | dependencies = [ |
| 247 | 247 | "anyhow", |
| 248 | 248 | "clap", |
+1-1Cargo.toml
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | [package] |
| 2 | 2 | name = "dothub" |
| 3 | -version = "0.1.0" | |
| 3 | +version = "0.1.1" | |
| 4 | 4 | edition = "2021" |
| 5 | 5 | description = "Minimal dotfile manager with a curated hub browser and fast linking" |
| 6 | 6 | license = "MIT OR Apache-2.0" |
+2-1README.md
| @@ -41,6 +41,7 @@ Usage | ||
| 41 | 41 | - List or remove installed repos: |
| 42 | 42 | - `dothub list` |
| 43 | 43 | - `dothub remove <name>` |
| 44 | + - Install with explicit name: `dothub install https://github.com/foo/bar my-bar` | |
| 44 | 45 | |
| 45 | 46 | Commands |
| 46 | 47 | - `dothub [TYPE[,TYPE...]] [--url <yaml-url>]` |
| @@ -50,7 +51,7 @@ Commands | ||
| 50 | 51 | - Post-table tips about `GITHUB_TOKEN` as applicable |
| 51 | 52 | - Filters by type(s) when provided (`nvim,tmux` or `nvim tmux`). |
| 52 | 53 | - Use `--url` to point at your own index file. |
| 53 | -- `dothub install <repo-url>` | |
| 54 | +- `dothub install <repo-url> [name]` | |
| 54 | 55 | - `dothub link <name> <target>` |
| 55 | 56 | - `dothub update` |
| 56 | 57 | - `dothub active` |
+3-2hub.yml
| @@ -1,8 +1,9 @@ | ||
| 1 | -# key: dotfile type, value: repo URL or list of URLs | |
| 1 | +# key: dotfile type, value: list of URLs | |
| 2 | 2 | nvim: |
| 3 | 3 | - https://github.com/huncholane/hygo-nvim |
| 4 | 4 | - https://github.com/LazyVim/LazyVim |
| 5 | -tmux: https://github.com/gpakosz/.tmux | |
| 5 | +tmux: | |
| 6 | + - https://github.com/gpakosz/.tmux | |
| 6 | 7 | zsh: |
| 7 | 8 | - https://github.com/ohmyzsh/ohmyzsh |
| 8 | 9 | - https://github.com/sorin-ionescu/prezto |
+9-3src/main.rs
| @@ -62,6 +62,9 @@ enum Commands { | ||
| 62 | 62 | struct InstallArgs { |
| 63 | 63 | /// Git repository URL, e.g. https://github.com/hygo-nvim |
| 64 | 64 | repo: String, |
| 65 | + /// Optional explicit name for the repo in the store | |
| 66 | + /// Example: dothub install https://github.com/foo/bar my-bar | |
| 67 | + name: Option<String>, | |
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | #[derive(Args)] |
| @@ -91,7 +94,7 @@ fn main() -> Result<()> { | ||
| 91 | 94 | let cli = Cli::parse(); |
| 92 | 95 | |
| 93 | 96 | match cli.command { |
| 94 | - Some(Commands::Install(args)) => cmd_install(&args.repo), | |
| 97 | + Some(Commands::Install(args)) => cmd_install(&args.repo, args.name.as_deref()), | |
| 95 | 98 | Some(Commands::Link(args)) => cmd_link(&args.name, &args.target), |
| 96 | 99 | Some(Commands::Update) => cmd_update(), |
| 97 | 100 | Some(Commands::Active) => cmd_active(), |
| @@ -130,11 +133,14 @@ fn derive_repo_name(repo_url: &str) -> String { | ||
| 130 | 133 | trimmed.rsplit('/').next().unwrap_or(trimmed).to_string() |
| 131 | 134 | } |
| 132 | 135 | |
| 133 | -fn cmd_install(repo: &str) -> Result<()> { | |
| 136 | +fn cmd_install(repo: &str, name_override: Option<&str>) -> Result<()> { | |
| 134 | 137 | ensure_store_dir()?; |
| 135 | 138 | |
| 136 | 139 | // Determine repo name |
| 137 | - let name = derive_repo_name(repo); | |
| 140 | + let name = match name_override { | |
| 141 | + Some(n) if !n.trim().is_empty() => n.trim().to_string(), | |
| 142 | + _ => derive_repo_name(repo), | |
| 143 | + }; | |
| 138 | 144 | if name.is_empty() { |
| 139 | 145 | bail!("Could not infer repository name from URL: {}", repo); |
| 140 | 146 | } |