irongit

The dotfiles manager.

refactor: rename project to dothub

huncholanehuncholaneauthored
parent 14cfedccommit 747d2c21fd763e16b48cf7a256df40e1da984a26Browse files

3 files changed, +28 -28

+1-1Cargo.lock
@@ -241,7 +241,7 @@ dependencies = [
241241 ]
242242
243243 [[package]]
244-name = "dotman"
244+name = "dothub"
245245 version = "0.1.0"
246246 dependencies = [
247247 "anyhow",
+1-1Cargo.toml
@@ -1,5 +1,5 @@
11 [package]
2-name = "dotman"
2+name = "dothub"
33 version = "0.1.0"
44 edition = "2021"
55
+26-26src/main.rs
@@ -13,13 +13,13 @@ use std::io::Write;
1313 use std::path::Path;
1414 use std::process::Command;
1515
16-const DOTMAN_DIR: &str = "/usr/local/share/dotman";
16+const DOTHUB_DIR: &str = "/usr/local/share/dothub";
1717 const DEFAULT_FLEX_URL: &str =
18- "https://raw.githubusercontent.com/huncholane/dotman/refs/heads/main/flex.yml";
18+ "https://raw.githubusercontent.com/huncholane/dothub/refs/heads/main/flex.yml";
1919 const GH_TOKEN_HELP_URL: &str = "https://github.com/settings/personal-access-tokens";
2020
2121 #[derive(Parser)]
22-#[command(name = "dotman", about = "Manage dotfile repos and links", version)]
22+#[command(name = "dothub", about = "Manage dotfile repos and links", version)]
2323 #[command(arg_required_else_help = true)]
2424 struct Cli {
2525 #[command(subcommand)]
@@ -28,15 +28,15 @@ struct Cli {
2828
2929 #[derive(Subcommand)]
3030 enum Commands {
31- /// Clone a git repository into the dotman store
31+ /// Clone a git repository into the dothub store
3232 Install(InstallArgs),
3333 /// Replace ~/.config/<target> with a symlink to a stored repo
3434 Link(LinkArgs),
3535 /// Pull latest changes for all stored repos
3636 Update,
37- /// List active links in ~/.config that point into dotman
37+ /// List active links in ~/.config that point into dothub
3838 Active,
39- /// List repositories installed in the dotman store
39+ /// List repositories installed in the dothub store
4040 List,
4141 /// Fetch and list repos from flex.yml (remote), sorted by GitHub stars
4242 Flex(FlexArgs),
@@ -62,7 +62,7 @@ struct InstallArgs {
6262
6363 #[derive(Args)]
6464 struct LinkArgs {
65- /// Repository name stored under dotman (e.g. hygo-nvim)
65+ /// Repository name stored under dothub (e.g. hygo-nvim)
6666 name: String,
6767 /// Target directory name under ~/.config (e.g. nvim, alacritty, fish)
6868 target: String,
@@ -91,11 +91,11 @@ fn main() -> Result<()> {
9191 }
9292 }
9393
94-fn ensure_dotman_dir() -> Result<()> {
95- let path = Path::new(DOTMAN_DIR);
94+fn ensure_store_dir() -> Result<()> {
95+ let path = Path::new(DOTHUB_DIR);
9696 if !path.exists() {
9797 fs::create_dir_all(path)
98- .with_context(|| format!("Failed creating {} (need sudo?)", DOTMAN_DIR))?;
98+ .with_context(|| format!("Failed creating {} (need sudo?)", DOTHUB_DIR))?;
9999 }
100100 Ok(())
101101 }
@@ -106,7 +106,7 @@ fn derive_repo_name(repo_url: &str) -> String {
106106 }
107107
108108 fn cmd_install(repo: &str) -> Result<()> {
109- ensure_dotman_dir()?;
109+ ensure_store_dir()?;
110110
111111 // Determine repo name
112112 let name = derive_repo_name(repo);
@@ -114,7 +114,7 @@ fn cmd_install(repo: &str) -> Result<()> {
114114 bail!("Could not infer repository name from URL: {}", repo);
115115 }
116116
117- let dest = Path::new(DOTMAN_DIR).join(&name);
117+ let dest = Path::new(DOTHUB_DIR).join(&name);
118118 if dest.exists() {
119119 println!("Repo already exists: {}", dest.display());
120120 return Ok(());
@@ -140,7 +140,7 @@ fn cmd_install(repo: &str) -> Result<()> {
140140 }
141141
142142 fn cmd_link(name: &str, target_name: &str) -> Result<()> {
143- let source = Path::new(DOTMAN_DIR).join(name);
143+ let source = Path::new(DOTHUB_DIR).join(name);
144144 if !source.exists() {
145145 bail!("Source repo not found: {}", source.display());
146146 }
@@ -197,16 +197,16 @@ fn cmd_link(name: &str, target_name: &str) -> Result<()> {
197197 }
198198
199199 fn cmd_update() -> Result<()> {
200- ensure_dotman_dir()?;
200+ ensure_store_dir()?;
201201 if which::which("git").is_err() {
202202 bail!("git is not installed or not found in PATH");
203203 }
204204
205- let root = Path::new(DOTMAN_DIR);
205+ let root = Path::new(DOTHUB_DIR);
206206 let mut updated = 0usize;
207207 let mut skipped = 0usize;
208208
209- for entry in fs::read_dir(root).with_context(|| format!("Reading {}", DOTMAN_DIR))? {
209+ for entry in fs::read_dir(root).with_context(|| format!("Reading {}", DOTHUB_DIR))? {
210210 let entry = entry?;
211211 let path = entry.path();
212212 if !path.is_dir() {
@@ -310,7 +310,7 @@ fn cmd_active() -> Result<()> {
310310
311311 let resolved = abs_target.canonicalize().unwrap_or(abs_target.clone());
312312
313- if resolved.starts_with(DOTMAN_DIR) {
313+ if resolved.starts_with(DOTHUB_DIR) {
314314 let name = path
315315 .file_name()
316316 .and_then(|s| s.to_str())
@@ -321,7 +321,7 @@ fn cmd_active() -> Result<()> {
321321 }
322322
323323 if found.is_empty() {
324- println!("No active dotman links in ~/.config.");
324+ println!("No active dothub links in ~/.config.");
325325 } else {
326326 for (name, target) in found {
327327 println!("{} -> {}", name, target.display());
@@ -331,10 +331,10 @@ fn cmd_active() -> Result<()> {
331331 }
332332
333333 fn cmd_list() -> Result<()> {
334- ensure_dotman_dir()?;
335- let root = Path::new(DOTMAN_DIR);
334+ ensure_store_dir()?;
335+ let root = Path::new(DOTHUB_DIR);
336336 let mut repos: Vec<String> = Vec::new();
337- for entry in fs::read_dir(root).with_context(|| format!("Reading {}", DOTMAN_DIR))? {
337+ for entry in fs::read_dir(root).with_context(|| format!("Reading {}", DOTHUB_DIR))? {
338338 let entry = entry?;
339339 let path = entry.path();
340340 if !path.is_dir() {
@@ -348,7 +348,7 @@ fn cmd_list() -> Result<()> {
348348 }
349349 repos.sort();
350350 if repos.is_empty() {
351- println!("No repositories installed in {}.", DOTMAN_DIR);
351+ println!("No repositories installed in {}.", DOTHUB_DIR);
352352 } else {
353353 for r in repos {
354354 println!("{}", r);
@@ -440,7 +440,7 @@ fn cmd_flex(args: FlexArgs) -> Result<()> {
440440 for (idx, (_ty, link, stars)) in detailed.into_iter().enumerate() {
441441 let rank = (idx + 1).to_string();
442442 let name = derive_repo_name(&link);
443- let installed = Path::new(DOTMAN_DIR).join(&name).exists();
443+ let installed = Path::new(DOTHUB_DIR).join(&name).exists();
444444 let installed_str = if installed { "y" } else { "n" };
445445 table.add_row(vec![rank, stars.to_string(), installed_str.to_string(), link]);
446446 }
@@ -482,7 +482,7 @@ fn start_spinner(message: &str) -> Arc<AtomicBool> {
482482
483483 fn fetch_text(url: &str) -> Result<String> {
484484 let client = reqwest::blocking::Client::builder()
485- .user_agent("dotman/0.1")
485+ .user_agent("dothub/0.1")
486486 .build()
487487 .context("building http client")?;
488488 let resp = client
@@ -543,7 +543,7 @@ fn github_stars(link: &str) -> Result<u64> {
543543
544544 let api = format!("https://api.github.com/repos/{}/{}", owner, repo);
545545 let client = reqwest::blocking::Client::builder()
546- .user_agent("dotman/0.1")
546+ .user_agent("dothub/0.1")
547547 .build()
548548 .context("building http client")?;
549549 let resp = client
@@ -608,7 +608,7 @@ fn github_stars_batch(links: &[String], token: Option<&str>) -> Result<HashMap<S
608608 }
609609
610610 let client = reqwest::blocking::Client::builder()
611- .user_agent("dotman/0.1")
611+ .user_agent("dothub/0.1")
612612 .build()
613613 .context("building http client")?;
614614