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

command: selectable output formats (JSON/YAML) #513

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jsleeio
Copy link
Contributor

@jsleeio jsleeio commented Feb 8, 2024

Give the user a choice of YAML or JSON output for all commands that emit either format. I have left the default format as YAML.

I have also removed the Entry: 123 output lines which seemed like they were intended for debugging. I'm happy to be wrong here and restore them (for YAML output only, as it's clearly incompatible with JSON).

As-implemented, this will break scripted usage for the below commands that default to JSON. Given the breakdown of YAML vs. JSON usage here I think this is the least-bad option.

The other options I considered were:

  • default to JSON (break most usage)
  • default to nothing and require a flag (break everyone's usage)
  • have a third 'auto' state that maintained the current behaviour (breaks rule of least surprise)

Commands emitting JSON (with this change they will emit YAML):

$ grep -l json.Marshal command/*go
command/addon_update.go
command/analytics_incident_show.go
command/analytics_service_show.go
command/analytics_team_show.go

Commands emitting YAML:

$ grep -l 'yaml\.Marshal' command/*go
command/addon_list.go
command/addon_show.go
command/escalation_policy_list.go
command/escalation_policy_show.go
command/event_orchestration_list.go
command/event_orchestration_show.go
command/incident_list.go
command/maintenance_window_list.go
command/maintenance_window_show.go
command/oncall_list.go
command/schedule_list.go
command/service_list.go
command/service_rule_list.go
command/service_rule_show.go
command/service_show.go
command/standard_list.go
command/standard_multi_resources_scores_list.go
command/standard_resource_scores_list.go
command/team_list.go
command/team_show.go
command/user_list.go
command/vendor_list.go
command/vendor_show.go

Give the user a choice of YAML or JSON output for all commands that emit
either format. I have left the default format as YAML.

I have also removed the `Entry: 123` output lines which seemed like they
were intended for debugging. I'm happy to be wrong here and restore them
(for YAML output only, as it's clearly incompatible with JSON).

As-implemented, this will break scripted usage for the below commands
that default to JSON. Given the breakdown of YAML vs. JSON usage here I
think this is the least-bad option.

The other options I considered were:

* default to JSON (break most usage)
* default to nothing and require a flag (break everyone's usage)
* have a third 'auto' state that maintained the current behaviour
  (breaks rule of least surprise)

Commands emitting JSON (with this change they will emit YAML):

    $ grep -l json.Marshal command/*go
    command/addon_update.go
    command/analytics_incident_show.go
    command/analytics_service_show.go
    command/analytics_team_show.go

Commands emitting YAML:

    $ grep -l 'yaml\.Marshal' command/*go
    command/addon_list.go
    command/addon_show.go
    command/escalation_policy_list.go
    command/escalation_policy_show.go
    command/event_orchestration_list.go
    command/event_orchestration_show.go
    command/incident_list.go
    command/maintenance_window_list.go
    command/maintenance_window_show.go
    command/oncall_list.go
    command/schedule_list.go
    command/service_list.go
    command/service_rule_list.go
    command/service_rule_show.go
    command/service_show.go
    command/standard_list.go
    command/standard_multi_resources_scores_list.go
    command/standard_resource_scores_list.go
    command/team_list.go
    command/team_show.go
    command/user_list.go
    command/vendor_list.go
    command/vendor_show.go
@jsleeio
Copy link
Contributor Author

jsleeio commented Mar 13, 2024

@ChuckCrawford any thoughts on this?

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.

None yet

1 participant