Skip to content

Commit

Permalink
dot -h displays help fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
pablopunk committed Nov 16, 2024
1 parent 15ec763 commit 3e6db58
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions dot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ local function parse_args()
mock_brew = true
elseif arg[i] == "--hooks" then
hooks_mode = true
elseif arg[i] == "-h" then
print([[
Usage: dot [options] [module/profile]
Options:
-f Force mode: replace existing configurations, backing them up to <config>.before-dot
--version Display the version of dot
--purge Purge mode: uninstall dependencies and remove configurations
--unlink Unlink mode: remove symlinks but keep the config files in their destination
--mock-brew Mock brew operations (for testing purposes)
--hooks Run hooks even if dependencies haven't changed
-h Display this help message
]])
os.exit(0)
else
table.insert(args, arg[i])
end
Expand Down
12 changes: 12 additions & 0 deletions spec/dot_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -474,4 +474,16 @@ return {
assert.is_true(is_link(settings), "Expected symlink for settings.json")
assert.is_true(is_link(keybindings), "Expected symlink for keybindings.json")
end)

it("should display help message with -h option", function()
-- Run dot.lua with -h option
local cmd = string.format("cd %q && HOME=%q lua %q -h", dotfiles_dir, home_dir, dot_executable)
local handle = io.popen(cmd)
local output = handle:read("*a")
handle:close()

-- Check if the output contains the expected start of the help message
local expected_start = "Usage: dot"
assert.is_true(output:find(expected_start, 1, true) ~= nil, "Help message not displayed correctly")
end)
end)

0 comments on commit 3e6db58

Please sign in to comment.