martindstone / pagerduty-cli

A command line interface for PagerDuty
MIT License
91 stars 12 forks source link

New lines in incident details when creating a new incident #20

Closed jdstone closed 3 years ago

jdstone commented 3 years ago

New lines using \n don't seem to be accepted when creating a new incident. However, it works when using the CURL command. Is this the expected outcome? Or should new lines work within pagerduty-cli?

pd incident:create -t "test incident" -u low --service_id=P53ZZH5 -U "me@example.com" -d "A disk is getting full on this machine.\nYou should investigate what is causing the disk to fill, and ensure that there is an automated process in place for ensuring data is rotated (eg. logs should have logrotate around them). If data is expected to stay on this disk forever, you should start planning to scale up to a larger disk."

I was successfully able to create new lines in the incident details when using the CURL command:

curl --request POST   --url https://api.pagerduty.com/incidents   --header 'Accept: application/vnd.pagerduty+json;version=2'   --header 'Authorization: Token token=<TOKEN_REDACTED>'   --header 'Content-Type: application/json'   --header 'From: me@example.com'   --data '{
  "incident": {
    "type": "incident",
    "title": "test incident.",
    "service": {
      "id": "P53ZZH5",
      "type": "service_reference"
    },
    "urgency": "low",
    "incident_key": "baf7cf21b1da41b4b0221008339ff357",
    "body": {
      "type": "incident_body",
      "details": "A disk is getting full on this machine.\nYou should investigate what is causing the disk to fill, and ensure that there is an automated process in place for ensuring data is rotated (eg. logs should have logrotate around them). If data is expected to stay on this disk forever, you should start planning to scale up to a larger disk."
    }
  }
}'
martindstone commented 3 years ago

oclif's flags preserve the escaped characters as escaped 😕 I am pushing a change now to unescape newlines and tabs, I don't think incident description allows anything else so I will leave it at that for now if that's ok

martindstone commented 3 years ago

Hi @jdstone , I uploaded 0.0.77 which allows \n and \t in incident description... can you let me know if it solves the issue for you?

jdstone commented 3 years ago

I can confirm that worked @martindstone. Thank you sir!