Skip to content

feat: Add default retrieve handler when passing an id to commands#345

Merged
blainekasten merged 1 commit intonextfrom
blaine/dx-535-add-shorthand-ergonomics
Apr 28, 2026
Merged

feat: Add default retrieve handler when passing an id to commands#345
blainekasten merged 1 commit intonextfrom
blaine/dx-535-add-shorthand-ergonomics

Conversation

@blainekasten
Copy link
Copy Markdown
Contributor

@blainekasten blainekasten commented Apr 27, 2026

This enables a short hand retrieve by matching the id style as a heurestic to assume retrieve.

E.g., the following is now possible and shows the related command:

short long
tg files file-xxx tg files retrieve file-xxx
tg evals eval-xxxxx-xxx tg evals retrieve eval-xxxxx-xxx
etc...

@blainekasten blainekasten force-pushed the blaine/dx-535-add-shorthand-ergonomics branch 2 times, most recently from 435289d to 19c7801 Compare April 27, 2026 20:09
@blainekasten blainekasten requested a review from zainhas April 27, 2026 20:16
@blainekasten blainekasten force-pushed the blaine/dx-535-add-shorthand-ergonomics branch 3 times, most recently from 7c8274e to 67a6943 Compare April 27, 2026 20:22
first = toks[0] if toks else ""
if re_identifier.match(first):
toks.insert(0, "retrieve")
command, bound, _unused, _ignored = app.parse_known_args(toks)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what happens here if someone types tg files random_stuff or just tg files with no args?

first won't match the regex, we don't insert retrieve, and then we re-call parse_known_args on the same tokens, doesn't that route back into this same default handler?

in that case I feel like a nice DX thing would be to insert tg files list and get a full table of all previous files

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.

So no, we are passing the "sub app" here, not the top level app. So the top level meta handler gets called only once.

@blainekasten blainekasten force-pushed the blaine/dx-535-add-shorthand-ergonomics branch 4 times, most recently from fddcf75 to 506323b Compare April 28, 2026 19:33
@blainekasten blainekasten force-pushed the blaine/dx-535-add-shorthand-ergonomics branch from 506323b to 638e436 Compare April 28, 2026 19:48
@blainekasten blainekasten merged commit 984519c into next Apr 28, 2026
9 checks passed
@stainless-app stainless-app Bot mentioned this pull request Apr 28, 2026
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.

2 participants