irongit

The dotfiles manager.

feat: named installs

huncholanehuncholaneauthored
parent 4d9af02commit 9d3ecc3a1e4b25ab5a0537e636847d2aab3dd069Browse files

5 files changed, +16 -8

+1-1Cargo.lock
@@ -242,7 +242,7 @@ dependencies = [
242242
243243 [[package]]
244244 name = "dothub"
245-version = "0.1.0"
245+version = "0.1.1"
246246 dependencies = [
247247 "anyhow",
248248 "clap",
+1-1Cargo.toml
@@ -1,6 +1,6 @@
11 [package]
22 name = "dothub"
3-version = "0.1.0"
3+version = "0.1.1"
44 edition = "2021"
55 description = "Minimal dotfile manager with a curated hub browser and fast linking"
66 license = "MIT OR Apache-2.0"
+2-1README.md
@@ -41,6 +41,7 @@ Usage
4141 - List or remove installed repos:
4242 - `dothub list`
4343 - `dothub remove <name>`
44+ - Install with explicit name: `dothub install https://github.com/foo/bar my-bar`
4445
4546 Commands
4647 - `dothub [TYPE[,TYPE...]] [--url <yaml-url>]`
@@ -50,7 +51,7 @@ Commands
5051 - Post-table tips about `GITHUB_TOKEN` as applicable
5152 - Filters by type(s) when provided (`nvim,tmux` or `nvim tmux`).
5253 - Use `--url` to point at your own index file.
53-- `dothub install <repo-url>`
54+- `dothub install <repo-url> [name]`
5455 - `dothub link <name> <target>`
5556 - `dothub update`
5657 - `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
22 nvim:
33 - https://github.com/huncholane/hygo-nvim
44 - https://github.com/LazyVim/LazyVim
5-tmux: https://github.com/gpakosz/.tmux
5+tmux:
6+ - https://github.com/gpakosz/.tmux
67 zsh:
78 - https://github.com/ohmyzsh/ohmyzsh
89 - https://github.com/sorin-ionescu/prezto
+9-3src/main.rs
@@ -62,6 +62,9 @@ enum Commands {
6262 struct InstallArgs {
6363 /// Git repository URL, e.g. https://github.com/hygo-nvim
6464 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>,
6568 }
6669
6770 #[derive(Args)]
@@ -91,7 +94,7 @@ fn main() -> Result<()> {
9194 let cli = Cli::parse();
9295
9396 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()),
9598 Some(Commands::Link(args)) => cmd_link(&args.name, &args.target),
9699 Some(Commands::Update) => cmd_update(),
97100 Some(Commands::Active) => cmd_active(),
@@ -130,11 +133,14 @@ fn derive_repo_name(repo_url: &str) -> String {
130133 trimmed.rsplit('/').next().unwrap_or(trimmed).to_string()
131134 }
132135
133-fn cmd_install(repo: &str) -> Result<()> {
136+fn cmd_install(repo: &str, name_override: Option<&str>) -> Result<()> {
134137 ensure_store_dir()?;
135138
136139 // 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+ };
138144 if name.is_empty() {
139145 bail!("Could not infer repository name from URL: {}", repo);
140146 }