Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ path = "src/main.rs"

[dependencies]
anyhow = "1"
clap = { version = "4", features = ["derive"] }
clap = { version = "4", features = ["derive", "env"] }
clap_complete = "4"
dirs = "6"
fs2 = "0.4"
Expand All @@ -29,7 +29,10 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
tera = "1"
crossterm = "0.29"
gix = { version = "0.84", default-features = false, features = ["revision", "sha1"] }
gix = { version = "0.84", default-features = false, features = [
"revision",
"sha1",
] }
nix = { version = "0.31", features = ["user", "fs"] }
sha2 = "0.11"
shellexpand = "3"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Variable precedence: **host vars > role vars** (last role listed wins among role
Override files sit next to the base file with a `##` suffix:

| Pattern | Priority | Description |
|---------|----------|-------------|
| --------- | ---------- | ------------- |
| `file##host.<hostname>` | 1 (highest) | Used only on the named host |
| `file##role.<rolename>` | 2 | Used when the role is active |
| `file.tera` | 3 | Tera template, rendered with vars |
Expand Down Expand Up @@ -329,7 +329,7 @@ dotm adopt # interactively adopt external changes back into source
Status markers:

| Marker | Meaning |
|--------|---------|
| -------- | --------- |
| `~` | File is OK (verbose mode only) |
| `M` | Content has been modified since last deploy |
| `!` | File is missing |
Expand All @@ -343,7 +343,7 @@ If a file was modified externally, re-deploying will skip it with a warning. Use
dotm [OPTIONS] <COMMAND>

Options:
-d, --dir <DIR> Path to dotfiles directory [default: .]
-d, --dir <DIR> Path to dotfiles directory (env: DOTM_DIR) [default: .]
-V, --version Print version

Commands:
Expand Down Expand Up @@ -490,7 +490,7 @@ dotm sync --system # sync system packages
## Comparison

| Feature | dotm | GNU stow | yadm | dotter |
|---------|------|----------|------|--------|
| --------- | ------ | ---------- | ------ | -------- |
| Symlink-based | Yes | Yes | Yes | Yes |
| Role/profile system | Yes | No | No | Yes |
| Host-specific overrides | Yes | No | Alt files | Yes |
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::path::PathBuf;
)]
struct Cli {
/// Path to the dotfiles directory (default: current directory)
#[arg(short, long, default_value = ".")]
#[arg(short, long, env = "DOTM_DIR", default_value = ".")]
dir: PathBuf,

#[command(subcommand)]
Expand Down
31 changes: 31 additions & 0 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,37 @@ fn cli_list_hosts() {
.stdout(predicate::str::contains("testhost"));
}

#[test]
fn cli_dotm_dir_env_var() {
let dotfiles = TempDir::new().unwrap();
copy_dir_recursive(Path::new("tests/fixtures/basic"), dotfiles.path());

// Without --dir, DOTM_DIR env var should be used
Command::cargo_bin("dotm")
.unwrap()
.env("DOTM_DIR", dotfiles.path().to_str().unwrap())
.args(["list", "packages"])
.assert()
.success()
.stdout(predicate::str::contains("shell"));
}

#[test]
fn cli_dir_flag_overrides_dotm_dir_env() {
let dotfiles = TempDir::new().unwrap();
let empty = TempDir::new().unwrap();
copy_dir_recursive(Path::new("tests/fixtures/basic"), dotfiles.path());

// --dir flag should take precedence over DOTM_DIR
Command::cargo_bin("dotm")
.unwrap()
.env("DOTM_DIR", empty.path().to_str().unwrap())
.args(["-d", dotfiles.path().to_str().unwrap(), "list", "packages"])
.assert()
.success()
.stdout(predicate::str::contains("shell"));
}

#[test]
fn cli_list_hosts_tree() {
let dotfiles = TempDir::new().unwrap();
Expand Down
Loading