[Feature Request] Add feature to format YAML output in blocks

Open
#83 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
cli

Research direction

Start by running the documented y rl ... | y --yaml rb --only=mp example and tracing the CLI path that produces YAML output. Add an optional --yaml-blocks mode while preserving the current default format; done means mappings are emitted in the requested block style, including empty mappings such as 30: {}.

Written by the indexing model from the issue text.

Description

feature help wanted

Currently a command such as y rl 11,12,13,14,15,16,20,30,40,50 | y --yaml rb --only=mp produces the following output:

11: {cyphal.l3xz-leg-ctrl.angle_offset_deg.a: 123.92578125, cyphal.l3xz-leg-ctrl.angle_offset_deg.b: 113.6865234375, cyphal.node.id: 11, cyphal.pub.AS5048_A.id: 1001, cyphal.pub.AS5048_B.id: 1002, cyphal.pub.bumper.id: 1003}
12: {cyphal.l3xz-leg-ctrl.angle_offset_deg.a: 0.0, cyphal.l3xz-leg-ctrl.angle_offset_deg.b: 0.0, cyphal.node.id: 12, cyphal.pub.AS5048_A.id: 1004, cyphal.pub.AS5048_B.id: 1005, cyphal.pub.bumper.id: 1006}
13: {cyphal.l3xz-leg-ctrl.angle_offset_deg.a: 0.0, cyphal.l3xz-leg-ctrl.angle_offset_deg.b: 0.0, cyphal.node.id: 13, cyphal.pub.AS5048_A.id: 1007, cyphal.pub.AS5048_B.id: 1008, cyphal.pub.bumper.id: 1009}
14: {cyphal.l3xz-leg-ctrl.angle_offset_deg.a: 0.0, cyphal.l3xz-leg-ctrl.angle_offset_deg.b: 0.0, cyphal.node.id: 14, cyphal.pub.AS5048_A.id: 1010, cyphal.pub.AS5048_B.id: 1011, cyphal.pub.bumper.id: 1012}
15: {cyphal.l3xz-leg-ctrl.angle_offset_deg.a: 0.0, cyphal.l3xz-leg-ctrl.angle_offset_deg.b: 0.0, cyphal.node.id: 15, cyphal.pub.AS5048_A.id: 1013, cyphal.pub.AS5048_B.id: 1014, cyphal.pub.bumper.id: 1015}
16: {cyphal.l3xz-leg-ctrl.angle_offset_deg.a: 0.0, cyphal.l3xz-leg-ctrl.angle_offset_deg.b: 0.0, cyphal.node.id: 16, cyphal.pub.AS5048_A.id: 1016, cyphal.pub.AS5048_B.id: 1017, cyphal.pub.bumper.id: 1018}
20: {cyphal.node.id: 20, cyphal.pub.estop.id: 2001, cyphal.sub.light_mode.id: 2002}
30: {}
40: {cyphal.node.id: 40, cyphal.sub.pulse_width.id: 4001}
50: {uavcan.node.id: 50, uavcan.pub.dynamics.id: 65535, uavcan.pub.dynamics.type: reg.udral.physics.dynamics.rotation.PlanarTs.0.1, uavcan.pub.esc_heartbeat.type: reg.udral.service.common.Heartbeat.0.1, uavcan.pub.feedback.id: 65535, uavcan.pub.feedback.type: reg.udral.service.actuator.common.Feedback.0.1, uavcan.pub.power.id: 65535, uavcan.pub.power.type: reg.udral.physics.electricity.PowerTs.0.1, uavcan.pub.status.id: 65535, uavcan.pub.status.type: reg.udral.service.actuator.common.Status.0.1, uavcan.sub.note_response.id: 65535, uavcan.sub.note_response.type: reg.udral.physics.acoustics.Note.0.1, uavcan.sub.readiness.id: 5001, uavcan.sub.readiness.type: reg.udral.service.common.Readiness.0.1, uavcan.sub.setpoint.id: 5002, uavcan.sub.setpoint.type: reg.udral.service.actuator.common.sp.Scalar.0.1}

When I afterwards manually edit the file I'd like to have it formatted in blocks, because that increases readability, i.e.

11:
  cyphal.pub.AS5048_A.id: 1001
  cyphal.pub.AS5048_B.id: 1002
  cyphal.pub.bumper.id: 1003
12:
  cyphal.pub.AS5048_A.id: 1004
  cyphal.pub.AS5048_B.id: 1005
  cyphal.pub.bumper.id: 1006
13:
  cyphal.pub.AS5048_A.id: 1007
  cyphal.pub.AS5048_B.id: 1008
  cyphal.pub.bumper.id: 1009
14:
  cyphal.pub.AS5048_A.id: 1010
  cyphal.pub.AS5048_B.id: 1011
  cyphal.pub.bumper.id: 1012
15:
  cyphal.pub.AS5048_A.id: 1013
  cyphal.pub.AS5048_B.id: 1014
  cyphal.pub.bumper.id: 1015
16:
  cyphal.pub.AS5048_A.id: 1016
  cyphal.pub.AS5048_B.id: 1017
  cyphal.pub.bumper.id: 1018
20:
  cyphal.pub.estop.id: 2001
  cyphal.sub.light_mode.id: 2002
30: {}
40:
  cyphal.sub.pulse_width.id: 4001
50:
  uavcan.sub.readiness.id: 5001
  uavcan.sub.setpoint.id: 5002

This could be a parameter like --yaml-blocks.

Dominant language
Python
Stars
69
Forks
14
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenCyphal/yakut

All issues in OpenCyphal/yakut

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.