Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]

### Added
- `query --include-full-path` flag to include absolute file path in JSON output
- Plugin system: executables named `tk-<cmd>` or `ticket-<cmd>` in PATH are invoked automatically
- `super` command to bypass plugins and run built-in commands directly
- `TICKETS_DIR` and `TK_SCRIPT` environment variables exported for plugins
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ Commands:
show <id> Display ticket
edit <id> Open ticket in $EDITOR
add-note <id> [text] Append timestamped note (or pipe via stdin)
query [jq-filter] Output tickets as JSON, optionally filtered
query [options] [jq-filter] Output tickets as JSON, optionally filtered
--include-full-path Include absolute file path in each JSON object
migrate-beads Import tickets from .beads/issues.jsonl
super <cmd> [args] Bypass plugins, run built-in command directly

Expand Down
24 changes: 24 additions & 0 deletions features/ticket_query.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,27 @@ Feature: Ticket Query
When I run "ticket query"
Then the command should succeed
And the JSONL deps field should be a JSON array

Scenario: Query with --include-full-path includes file path
Given a ticket exists with ID "query-001" and title "Path ticket"
When I run "ticket query --include-full-path"
Then the command should succeed
And the output should be valid JSONL
And the JSONL output should have field "full_path"
And the output should contain "query-001.md"

Scenario: Query with --include-full-path and jq filter
Given a ticket exists with ID "query-001" and title "Open path ticket"
And a ticket exists with ID "query-002" and title "Closed path ticket"
And ticket "query-002" has status "closed"
When I run "ticket query --include-full-path '.status == \"open\"'"
Then the command should succeed
And the JSONL output should have field "full_path"
And the output should contain "query-001"
And the output should not contain "query-002"

Scenario: Query without --include-full-path excludes file path
Given a ticket exists with ID "query-001" and title "No path ticket"
When I run "ticket query"
Then the command should succeed
And the output should not contain "full_path"
16 changes: 13 additions & 3 deletions ticket
Original file line number Diff line number Diff line change
Expand Up @@ -1319,11 +1319,17 @@ cmd_edit() {
}

cmd_query() {
local filter="${1:-}"
local filter="" include_full_path=0
while [[ $# -gt 0 ]]; do
case "$1" in
--include-full-path) include_full_path=1; shift ;;
*) filter="$1"; shift ;;
esac
done

# Generate all JSON in one awk pass
local json_output
json_output=$(awk '
json_output=$(awk -v include_path="$include_full_path" '
BEGIN { FS=": "; in_front=0 }
FNR==1 {
if (prev_file) emit()
Expand Down Expand Up @@ -1361,6 +1367,9 @@ cmd_query() {
printf "\"%s\":\"%s\"", key, val
}
}
if (include_path == 1) {
printf ",\"full_path\":\"%s\"", prev_file
}
printf "}\n"
}
}
Expand Down Expand Up @@ -1502,7 +1511,8 @@ Commands:
show <id> Display ticket
edit <id> Open ticket in \$EDITOR
add-note <id> [text] Append timestamped note (or pipe via stdin)
query [jq-filter] Output tickets as JSON, optionally filtered
query [options] [jq-filter] Output tickets as JSON, optionally filtered
--include-full-path Include absolute file path in each JSON object
migrate-beads Import tickets from .beads/issues.jsonl
super <cmd> [args] Bypass plugins, run built-in command directly
EOF
Expand Down