Skip to content

feat(cli): add dispatch path to print a session directory#332

Merged
jongio merged 2 commits into
mainfrom
idea/path-command
Jul 20, 2026
Merged

feat(cli): add dispatch path to print a session directory#332
jongio merged 2 commits into
mainfrom
idea/path-command

Conversation

@jongio

@jongio jongio commented Jul 19, 2026

Copy link
Copy Markdown
Owner

What

Adds a dispatch path command that prints only a session's working directory, so you can change into it from a subshell:

cd "$(dispatch path 0a1b2c3d)"   # by ID or short prefix
cd "$(dispatch path my-alias)"   # by alias
cd "$(dispatch path --last)"     # most recently active session
cd "$(dispatch path --current)"  # match the current repo and branch

Why

dispatch info prints a full summary and dispatch open --print prints a resume command. Neither gives you just the directory, so scripting a cd into a session folder meant parsing output. path fills that gap with a single-line, cd-friendly result.

Details

  • Resolves the session the same way open does (full ID, alias, short ID prefix, --last, --current) by reusing open's resolver seams, so matching rules stay identical.
  • Writes the absolute directory plus a trailing newline and nothing else.
  • Exits with an error if the session has no recorded directory or if that directory no longer exists on disk, so cd "$(...)" fails loudly instead of landing somewhere wrong.
  • Wires the command into the CLI dispatch switch, the four shell completion lists (bash, zsh, fish, powershell), the usage banner, the man examples, the README, and the changelog.

Tests

  • parsePathArgs table tests: id, alias, --last, -l, --current, and the error cases (no selector, combined selectors, extra args, unknown flag).
  • runPath tests via the seam stubs: resolve by ID, by alias, --last, --current, empty-directory error, missing-directory error, unknown ID.

Verification

go build ./..., go vet ./..., go test ./..., golangci-lint run, and mage deadcode all pass.

Closes #330

Add a `dispatch path <id|--last|--current>` command that prints only a
session's working directory, so you can `cd "$(dispatch path x)"`. It
resolves the session the same way `dispatch open` does (full ID, alias,
short ID prefix, --last, --current) by reusing open's resolver seams.

It errors when the session has no recorded directory or when that
directory no longer exists on disk, so `cd "$(...)"` fails loudly instead
of landing in the wrong place.

Wires the command into the CLI dispatch switch, the four shell completion
lists, the usage banner, the man examples, the README, and the changelog.

Closes #330

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 732fe147-a68b-4784-8e17-ef089fb70ba3
@jongio jongio added the idea Feature idea from the idea pipeline label Jul 19, 2026
@jongio jongio self-assigned this Jul 19, 2026
# Conflicts:
#	CHANGELOG.md
#	cmd/dispatch/cli.go
#	cmd/dispatch/main.go
@jongio
jongio merged commit 2291db4 into main Jul 20, 2026
2 checks passed
@jongio
jongio deleted the idea/path-command branch July 20, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

idea Feature idea from the idea pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add dispatch path to print a session working directory for cd

1 participant