PagerDuty / go-pagerduty

go client library for PagerDuty v2 API
https://v2.developer.pagerduty.com/docs/rest-api
Apache License 2.0
285 stars 241 forks source link

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

Open jsleeio opened 7 months ago

jsleeio commented 7 months ago

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:

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 commented 5 months ago

@ChuckCrawford any thoughts on this?