Context
Agents frequently chain CLI commands together, passing the output of one as input to another. Currently, extracting a single field requires --format json plus jq:
productive tasks add --title "Bug fix" --project 123 --task-list 456 --format json | jq -r '.id'
Not all environments have jq, and this adds friction for agent workflows.
Proposal
Add --output-field <field> (alias --of) that prints only the value of a specific field from the result:
# Get just the ID of a newly created task
TASK_ID=$(productive tasks add --title "Bug fix" --project 123 --task-list 456 --output-field id)
# Chain: create time entry for a task's service
productive time add \
--service $(productive tasks get 123 --output-field service_id) \
--time 60
# Get the URL of a project
productive projects get 123 --output-field productive_url
Behavior
- Prints the raw value (no quotes, no newline decoration) to stdout
- Works with any format's underlying data (extracts from the formatted resource object)
- Supports dot notation for nested fields:
--output-field relationships.project.id
- If the field doesn't exist, exit with error code and message to stderr
- Implies
--quiet (no spinners, no status messages)
Implementation
- Parse
--output-field in the global options
- After the command produces its result data, extract the field and print it
- Could be implemented as a post-processing step in
OutputFormatter or in runCommand
Context
Agents frequently chain CLI commands together, passing the output of one as input to another. Currently, extracting a single field requires
--format jsonplusjq:Not all environments have
jq, and this adds friction for agent workflows.Proposal
Add
--output-field <field>(alias--of) that prints only the value of a specific field from the result:Behavior
--output-field relationships.project.id--quiet(no spinners, no status messages)Implementation
--output-fieldin the global optionsOutputFormatteror inrunCommand