Skip to content

feat: Task and hook management via CLI commands#166

Draft
Copilot wants to merge 4 commits intomasterfrom
copilot/manage-tasks-hooks-cli
Draft

feat: Task and hook management via CLI commands#166
Copilot wants to merge 4 commits intomasterfrom
copilot/manage-tasks-hooks-cli

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 12, 2026

Adds CLI sub-commands to list, add, update, and remove tasks and hooks directly from the terminal, without manually editing task-runner.json or .husky/ files.

Description

Adds CLI sub-commands to list, add, update, and remove tasks and hooks directly from the terminal, without manually editing task-runner.json or .husky/ files.

All task commands support both a one-liner mode (pass all options as flags) and an interactive wizard mode (run without options to be guided through a step-by-step form powered by Spectre.Console).

New Commands

Tasks (task-runner.json manipulation via System.Text.Json.Nodes — preserves schema, variables, and all existing content):

  • dotnet husky task list (alias: task ls) — list all tasks
  • dotnet husky task add [-n <name>] [-c <command>] [-a <args>...] [-g <group>] [--branch] [--cwd] [--path-mode] [-o <output>] [--include] [--exclude] — add a task; launches interactive wizard if --name or --command is omitted
  • dotnet husky task update [-n <name>] [-c <cmd>] [-a <args>...] [-g <group>] [--branch] [--cwd] [--path-mode] [-o <output>] [--include] [--exclude] — update a task; launches interactive wizard with task-selection prompt if --name is omitted
  • dotnet husky task remove (alias: task rm) -n <name> — remove a task by name

Hooks (operates on .husky/ directory):

  • dotnet husky hook list (alias: hook ls) — list hook scripts (excludes files with extensions)
  • dotnet husky hook remove (alias: hook rm) <hook-name> — delete a hook file

Interactive Wizard

When task add or task update is run without providing required options, a Spectre.Console-powered wizard guides the user through all task properties:

  • task add: prompts for name, command, args, group, cwd, branch, pathMode (selection), output mode (selection), include/exclude patterns
  • task update: first presents a selection list of all existing tasks, then prompts for each field with current values pre-filled

Implementation Notes

  • All commands follow existing patterns: CommandBase, constructor DI with IGit/IFileSystem, registered in Program.cs
  • Shortcut aliases (task ls, task rm, hook ls, hook rm) are implemented as thin subclasses of the full-name commands
  • hook remove validates against Path.DirectorySeparatorChar / Path.AltDirectorySeparatorChar to correctly prevent path traversal
  • 17 new unit tests added using NSubstitute mocks, consistent with existing test style

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works
  • I have made corresponding changes to the documentation
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • I did test corresponding changes on Windows
  • I did test corresponding changes on Linux
  • I did test corresponding changes on Mac
Original prompt

This section details on the original issue you should resolve

<issue_title>Task and Hook management using CLI commands</issue_title>
<issue_description>### Details

It would be nice if we were able to see the tasks with something like dotnet husky task ls and be able to modify or remove it from CLI using its name. and the same feature for managing hooks</issue_description>

<agent_instructions>for managing hooks and tasks via the CLI, add,remove,modify,list etc</agent_instructions>

Comments on the Issue (you are @copilot in this section)


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI and others added 2 commits March 12, 2026 18:12
Co-authored-by: alirezanet <7004080+alirezanet@users.noreply.github.com>
Co-authored-by: alirezanet <7004080+alirezanet@users.noreply.github.com>
Copilot AI changed the title [WIP] Add task and hook management using CLI commands feat: Task and hook management via CLI commands Mar 12, 2026
Copilot AI requested a review from alirezanet March 12, 2026 18:16
Copy link
Copy Markdown
Owner

@alirezanet alirezanet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks ok, but feel free to use the spectre.console package to make the add or update calls more interactive if needed. user should be able to use the cli tool to change any part of the task they want or define a task as they want. I think plus supporting one liner commands we should also support a interactive wizard like form to guide and help users in all steps and for all properties.

Comment thread src/Husky/Cli/HookListCommand.cs Outdated

namespace Husky.Cli;

[Command("hook ls", Description = "List all husky hooks")]
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hook commands doesn't need to be one level nested since the add is also a hook command.

should be just list if possible also support shortcuts like ls

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to hook list in commit 5a1d410. Also added hook ls as a shortcut alias.

Comment thread src/Husky/Cli/HookRemoveCommand.cs Outdated

namespace Husky.Cli;

[Command("hook rm", Description = "Remove a husky hook")]
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hook commands doesn't need to be one level nested since the add is also a hook command.

it should be remove if possible also support shortcuts like rm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to hook remove in commit 5a1d410. Also added hook rm as a shortcut alias.

Comment thread src/Husky/Cli/TaskListCommand.cs Outdated

namespace Husky.Cli;

[Command("task ls", Description = "List all tasks in task-runner.json")]
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list is better I think, if possible also support shortcuts like ls

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to task list in commit 5a1d410. Also added task ls as a shortcut alias.

Comment thread src/Husky/Cli/TaskRemoveCommand.cs Outdated

namespace Husky.Cli;

[Command("task rm", Description = "Remove a task from task-runner.json")]
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be remove if possible also support shortcuts like rm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to task remove in commit 5a1d410. Also added task rm as a shortcut alias.

…ve wizard

Co-authored-by: alirezanet <7004080+alirezanet@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 12, 2026

it looks ok, but feel free to use the spectre.console package to make the add or update calls more interactive if needed. user should be able to use the cli tool to change any part of the task they wa...

Added Spectre.Console interactive wizard to task add and task update in commit 5a1d410. When run without options, both commands launch a step-by-step wizard covering all task properties: name, command, args, group, cwd, branch, pathMode, output, include, and exclude. task update additionally presents a selection prompt to choose which existing task to edit, with current values pre-filled. One-liner mode still works unchanged.

Copilot AI requested a review from alirezanet March 12, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task and Hook management using CLI commands

2 participants