Skip to content

refactor(cli): extract move and relation commands into focused modules - #272

Merged
ruby-automation merged 3 commits into
mainfrom
EXT-54-split-move-and-relations-remove-commands
Sep 12, 2026
Merged

refactor(cli): extract move and relation commands into focused modules#272
ruby-automation merged 3 commits into
mainfrom
EXT-54-split-move-and-relations-remove-commands

Conversation

@ruby-automation

Copy link
Copy Markdown
Contributor

Summary

  • Extracts issue_move into LinearCli.CLI.Commands.Issues.Move and all four relation functions into LinearCli.CLI.Commands.Issues.Relations
  • Deletes the now-empty monolithic commands.ex and the monolithic issue_commands_test.exs
  • Replaces them with move_test.exs (20 tests) and relations_test.exs (38 tests), both async: true
  • Updates cli.ex dispatch aliases; updates AGENTS.md module map

Closes EXT-54. Completes phase-18 of the CLI refactoring plan.

Test plan

  • mix test — 493 tests, 0 failures
  • mix format --check-formatted — clean
  • mix credo --strict — no issues
  • git push pre-push hooks pass (format + credo + test subset)
  • No stale bare alias LinearCli.CLI.Commands references remain

🤖 Generated with Claude Code

Completes EXT-54 (phase 18): extracts `issue_move` and
`issue_relation_{list,add,remove}` from the monolithic
`LinearCli.CLI.Commands` module into `Issues.Move` and
`Issues.Relations`. Deletes the now-empty `commands.ex` and the
monolithic `issue_commands_test.exs`, replacing them with
`move_test.exs` and `relations_test.exs`. Updates `cli.ex` dispatch
aliases accordingly and updates the AGENTS.md module map.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Add relation route-level coverage and correct the inaccurate module-map documentation.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Refactors issue move and relation CLI commands into focused modules, splitting tests and updating dispatch documentation.

Changes:

  • Added dedicated Move and Relations command modules.
  • Updated CLI dispatch aliases.
  • Replaced monolithic issue-command tests with focused suites.
  • Updated the CLI module map.
File summaries
File Summary
app/test/linear_cli/cli/issue_commands_test.exs Removed monolithic issue-command tests.
app/test/linear_cli/cli/commands/issues/relations_test.exs Added focused relation command tests.
app/test/linear_cli/cli/commands/issues/move_test.exs Added focused move command tests.
app/lib/linear_cli/cli/commands/issues/relations.ex Extracted issue relation commands.
app/lib/linear_cli/cli/commands/issues/move.ex Extracted issue move command.
app/lib/linear_cli/cli.ex Updated command dispatch; relation routes need end-to-end smoke coverage.
AGENTS.md Updated module map; corrections are needed for command ownership documentation.
Review details

Suppressed comments (1)

AGENTS.md:88

  • The updated module map says Mutations contains label commands, but this module's public commands are update, comment, status, and assign (app/lib/linear_cli/cli/commands/issues/mutations.ex:1-5,30,79,110,128). This omits the actual issue update command and documents a nonexistent label subcommand; please correct the list.
  CLI.Commands.Issues.Mutations      — issue status/assign/label/comment subcommands
  • Files reviewed: 7/7 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/lib/linear_cli/cli.ex
Comment thread AGENTS.md Outdated

@bougyman bougyman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Get rid of the regex and if then else, replace with matching function signatures.

Comment thread app/lib/linear_cli/cli/commands/issues/move.ex Outdated
Comment thread app/lib/linear_cli/cli/commands/issues/move.ex Outdated
Comment thread app/lib/linear_cli/cli/commands/issues/move.ex Outdated
…odule map, relation smoke tests

- Replace UUID regex + if/else in resolve_bulk_project with two function
  clauses: binary pattern <<_::8*8, ?-, _::4*8, ...>> for UUID shape,
  plain name lookup otherwise
- Replace if/else in show_move_results with two function clauses keyed
  on the "json" output mode
- Remove false Ruby attribution from Move moduledoc
- Fix AGENTS.md module map: split System into System/Profiles/Teams/Projects
  entries, correct Mutations description to update/status/assign/comment
- Add route-level smoke tests for issue relation list/add/remove via
  LinearCli.CLI.main/1, covering the dispatch paths not exercised by the
  direct-module tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ruby-automation

Copy link
Copy Markdown
Contributor Author

Rework summary

Addressed all review comments from bougyman and Copilot.

Changes made

bougyman: move.ex:4 — false Ruby attribution
Removed the "Ported from vendor/ruby-linear-cli/…" line from the Move moduledoc.

bougyman: move.ex:130,165 — regex and if/then/else
Replaced @uuid_regex + Regex.match? + if/else in resolve_bulk_project with two function clauses using Elixir binary pattern matching:

  • UUID clause: <<_::8*8, ?-, _::4*8, ?-, _::4*8, ?-, _::4*8, ?-, _::12*8>> = uuid — matches the 8-4-4-4-12 UUID structure by shape
  • Name/search clause: falls through to the existing team project lookup

Also replaced the if output == "json" branch in show_move_results with two function clauses keyed on the "json" output pattern.

Copilot: AGENTS.md:84 — incorrect module map
Split the single CLI.Commands.System entry into four accurate entries:

  • CLI.Commands.System — whoami, version
  • CLI.Commands.Profiles — profile create/list/use/show/clear/delete
  • CLI.Commands.Teams — team list/favorite/unfavorite
  • CLI.Commands.Projects — project list/favorite/unfavorite/update

Fixed CLI.Commands.Issues.Mutations description from "status/assign/label/comment" to "update/status/assign/comment" (label was never a subcommand there).

Copilot: cli.ex:250 — missing route-level coverage for relation dispatch
Added a new describe "relation dispatch routes (smoke)" block to relations_test.exs with three tests that call LinearCli.CLI.main/1 end-to-end for issue relation list, issue relation add, and issue relation remove, verifying the dispatch path produces correct output.

Result

496 tests pass (up from 493), format clean, credo clean.

@ruby-automation

Copy link
Copy Markdown
Contributor Author

Rework summary

Review comments addressed

bougyman — move.ex:4: Removed the inaccurate "Ported from vendor/ruby-linear-cli" moduledoc note; the move command was written fresh for this project.

bougyman — move.ex:130 & 165: Replaced @uuid_regex and the if Regex.match?(...) / if-then-else in resolve_bulk_project/2 with two function clauses using binary pattern matching:

# UUID by structure: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
defp resolve_bulk_project(<<_::8*8, ?-, _::4*8, ?-, _::4*8, ?-, _::4*8, ?-, _::12*8>> = uuid, _team_fn) do
  short_name = String.slice(uuid, 0, 8) <> "…"
  {:ok, struct(LinearCli.Linear.Project, %{id: uuid, name: short_name})}
end

defp resolve_bulk_project(value, team_fn) do
  # name/search lookup...
end

Also replaced the if output == "json" block in show_move_results/4 with two function-head clauses matching on the "json" literal.

Copilot — cli.ex:250: Added a describe "issue relation routes" block with three LinearCli.CLI.main/1 smoke tests — one each for issue relation list, issue relation add, and issue relation remove — confirming the dispatch table routes to the correct handlers.

Copilot — AGENTS.md:84 & 88: Fixed the module map:

  • CLI.Commands.System now correctly shows whoami/version only
  • Added separate entries for CLI.Commands.Profiles, CLI.Commands.Teams, CLI.Commands.Projects
  • CLI.Commands.Issues.Mutations now shows update/status/assign/comment (removed the erroneous "label" entry)

Result

496 tests pass (3 new route smoke tests added), format clean, credo clean.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ruby-automation
ruby-automation dismissed bougyman’s stale review September 12, 2026 17:42

All requested changes addressed: regex replaced with binary pattern matching, false attributions removed, module map corrected, route smoke tests added.

@ruby-automation
ruby-automation merged commit 97b1ca9 into main Sep 12, 2026
3 checks passed
@ruby-automation
ruby-automation deleted the EXT-54-split-move-and-relations-remove-commands branch September 12, 2026 17:44
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.

3 participants