Repository navigation
feat(cli): -o name prints the identifier of each object, what the command that reads it takes - #569
Merged
Merged
Conversation
…ommand that reads it takes A reply model marks the one field its resource's read command takes with `Identity()`; `-o name` prints it on a line for each item, so `ycli … list -o name | xargs -n1 ycli … get` works, and `create -o name` gives the key of what was made. An object inside another one prints its own identifier. A command whose result has no such field is refused before it sends anything (exit code 2). A reply that leaves the identifier of an item out is an error and nothing is printed, so a script never acts on fewer objects than were listed. The plan of `--dry-run` is printed as JSON. The hand-written models of Tracker, Wiki and Forms are marked (82 fields). The models generated from the DataLens specification are not: their resources will name the identifier where the generator reads it, in the next change. Decisions of #561 (Р1-А, Р2-А, Р2-Г) and #498. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 10, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second of the two output-format PRs decided in #561 (and #498); the first was #568.
What it does
-o nameprints the identifier of each object on a line: the field the command that reads it takes.ycli tracker issues search 'Queue: TEST' -o name | xargs -n1 ycli tracker issues getworks, andissues create … -o namegives the key of what was made.Identity()(Р1-А: the same mark, no second one; it stays inycli/yandex/sync/marks.py, andlint-importskeeps all 6 contracts).YandexUnexpectedReplyError, exit code 1) and nothing is printed, so a script never acts on fewer objects than were listed.--dry-runthe plan comes back in place of the object and is printed as JSON. An item that is not an object (a tag) is its own name.Coverage
The 34 are every DataLens listing (27 generated item classes behind one reason) and five classes with no identifier of their own, each with its reason in
NO_NAMEoftests/architecture/test_names.py. The 213 are acknowledgements, counts, operation statuses, permissions — and the DataLens single objects, which the next PR names.DataLens is not in this PR. Its models are generated from the specification and are not edited by hand. The next PR lets each DataLens resource name the API key of its identifier where the generator reads it; the test here fails the day no generated model is left unnamed, so the reason cannot outlive its cause.
Checks added
tests/architecture/test_names.py: the item class of every listing has exactly oneIdentity()field or a stated reason, checked both ways, with a biting case; and everycreate/get/updateof a resource whose listing prints names prints one too (holds with no exception).tests/contract/test_output_formats.py: every contract case that has a command (723) under-o nameprints one non-empty line per item that is a value of that item, or exits 2 with the refusal while the mock saw no request. Seven operations have a case whose reply leaves the identifier out; they are named in the test and assert the error, both ways. Their replies are unchanged.tests/unit/cli/test_inject.py:-o nameis recognised as the text typer holds before the command runs.A defect the bite pass found, and its evidence
In an earlier commit of this branch the refusal never fired when
--format namestood before the command: the code compared the choice withis, and typer holds it as text there. The per-case test was green anyway, because its "text, a count, bytes print the same in every format" escape accepted any output equal to-o json. Both are fixed. Measured both ways on the per-case test: intact → 724 passed; refusal disabled → 312 failed, 411 passed. The unit test above fails withisand passes with==.Other checks seen failing on their defect, then restored: a listing item losing its mark (the architecture test failed); an unnamed item printing an empty line (the sparse-operations test and the unit test failed).
Checked
uv run pytest: 6951 passed, 5 skipped, coverage 100% (lines and branches);lint-imports,ty,ruffclean. That run was on the tree before the last edit, which added anArgs:section to one docstring; after it the CLI unit tests, the architecture test, the contract format tests and the doctests ofoutput.pywere rerun (1893 passed) and the pre-commit hooks passed.Not run
-o name | xargs … getwas not tried against Tracker, Wiki or Forms.The marked fields
82 fields in 54 files, put there by a one-off codemod (not in the repository). The field is what the resource's read command takes; where a resource has
getandget-by-id, plaingetdecides.forms.answers.models.AnswerDetailsidgetto decide:key, elseslug, elseidforms.answers.models.AnswerIntegrationidgetto decide:key, elseslug, elseidforms.filling.models.FillableFormidgetargumentforms.filling.models.SubmitResultidgetargumentforms.filling.models.Suggestionidgetargument, checked by hand against its helpforms.history.models.HistoryEventidgetto decide:key, elseslug, elseidforms.hooks.models.Hookidgetargumentforms.images.models.Imageidgetto decide:key, elseslug, elseidforms.keysets.models.Keysetidgetargumentforms.me.models.Useridgetto decide:key, elseslug, elseidforms.models.Conditionidgetargumentforms.models.OperationResultidgetargumentforms.notifications.models.Notificationidgetargumentforms.notifications.models.NotificationActionidgetargumentforms.notifications.models.NotificationDetailsidgetargumentforms.notifications.models.NotificationStatusidgetargumentforms.questions.models.Questionidgetargument, checked by hand against its helpforms.questions.models.QuestionMoveResultidgetargumentforms.subscriptions.models.EmailSubscriptionidgetargumentforms.subscriptions.models.FunctionSubscriptionidgetargumentforms.subscriptions.models.HTTPSubscriptionidgetargumentforms.subscriptions.models.JSONRPCSubscriptionidgetargumentforms.subscriptions.models.TrackerCommentSubscriptionidgetargumentforms.subscriptions.models.TrackerSubscriptionidgetargumentforms.subscriptions.models.WikiSubscriptionidgetargumentforms.surveys.models.Surveyidgetargumentforms.variables.models.VariableInfonameid; a variable is called by its namestatus.models.SavedProfilename--profiletakes the namesync.files.FileStatepathsync.kind.KindSummaryname--kindtakes the namesync.plan.Plannedpathsync.pull.Pulledpathsync.push.Pushedpathtracker.attachments.models.Attachmentidgetargumenttracker.autoactions.models.Autoactionidgetargumenttracker.autoactions.models.AutoactionLogEntryidgetargumenttracker.autoactions.models.AutoactionRunEntryidgetargumenttracker.boards.models.Boardidgetargumenttracker.bulk.models.BulkChangeidgetargumenttracker.bulk.models.BulkIssueResultissuetracker.changelog.models.ChangelogEntryidgetto decide:key, elseslug, elseidtracker.columns.models.Columnidgetargumenttracker.comments.models.Commentidgetargumenttracker.components.models.Componentidgetargumenttracker.dashboards.models.Dashboardidgetto decide:key, elseslug, elseidtracker.dashboards.models.Widgetidgetto decide:key, elseslug, elseidtracker.entities.models.Attachmentidgetargumenttracker.entities.models.BulkChangeOperationidgetargumenttracker.entities.models.Commentidgetargumenttracker.entities.models.Entityidgetargumenttracker.entities.models.EntityEventidgetargumenttracker.fields.models.CustomFieldidgetargument, checked by hand against its helptracker.fields.models.FieldCategoryRecordidgetargumenttracker.filters.models.Filteridgetargumenttracker.issuetypes.models.IssueTypekeygetto decide:key, elseslug, elseidtracker.links.models.Linkidgetto decide:key, elseslug, elseidtracker.localfields.models.LocalFieldkeygetargumenttracker.macros.models.Macroidgetargumenttracker.models.Applicationidgetto decide:key, elseslug, elseidtracker.models.Issuekeygetargumenttracker.models.IssueChecklistItemidgetto decide:key, elseslug, elseidtracker.models.LinkTypeidgetto decide:key, elseslug, elseidtracker.models.Userloginusers gettakes a logintracker.priorities.models.Prioritykeygetto decide:key, elseslug, elseidtracker.projects.models.Projectidgetargument, checked by hand against its helptracker.queues.models.Queuekeyqueues gettakes a key or an idtracker.queues.models.QueueFieldidgetargumenttracker.queues.models.QueueVersionInfoidgetargumenttracker.remotelinks.models.RemoteLinkidgetto decide:key, elseslug, elseidtracker.resolutions.models.Resolutionkeygetto decide:key, elseslug, elseidtracker.sprints.models.Sprintidgetargumenttracker.statuses.models.Statuskeygetto decide:key, elseslug, elseidtracker.transitions.models.Transitionidgetto decide:key, elseslug, elseidtracker.triggers.models.Triggeridgetargumenttracker.triggers.models.WebhookLogEntryidgetargumenttracker.workflows.models.Workflowidgetargumenttracker.worklog.models.Worklogidgetto decide:key, elseslug, elseidwiki.access.models.PageAccessidgetto decide:key, elseslug, elseidwiki.attachments.models.AttachedFileidgetargumentwiki.comments.models.Commentidgetto decide:key, elseslug, elseidwiki.comments.models.CommentCreatedidgetto decide:key, elseslug, elseidwiki.grids.models.ColumnSuggestionsluggetto decide:key, elseslug, elseidwiki.grids.models.Grididgetargumentwiki.pages.models.GridRefidgetto decide:key, elseslug, elseidwiki.pages.models.PageDetailssluggetargumentwiki.pages.models.PageRefsluggetargumentwiki.pages.models.PageRevisionidgetto decide:key, elseslug, elseidwiki.recovery.models.RecoveredPagesluggetto decide:key, elseslug, elseidwiki.uploadsessions.models.UploadSessionsession_idgetargument, checked by hand against its help🤖 Generated with Claude Code