Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aentinger opened this issue Apr 28, 2023 · 1 comment
Open

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

aentinger opened this issue Apr 28, 2023 · 1 comment

Comments

@aentinger
Copy link

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.

@pavel-kirienko
Copy link
Member

This is easy to implement by adding a new formatter here:

_FORMATTERS = {
"AUTO": _make_auto,
"YAML": _make_yaml_formatter,
"JSON": _make_json_formatter,
"TSV": _make_tsv_formatter,
"TSVH": _make_tsvh_formatter_factory(with_format_specifiers=False),
"TSVFC": _make_tsvh_formatter_factory(with_format_specifiers=True),
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants