ankitpokhrel/jira-cli

issue edit: newline in body does not work

Closed this issue · 3 comments

Describe the bug
I want to update the body of an issue with

jira issue edit issue-001 -b "Line 1  \nLine 2  \n\nanother line"

I expected that \n would be interpreted as newline but it is just added to the body as plain text .
This is how the decription looks like in the jira webui.
Line 1 \nLine 2 \n\nanother line

I also tried to use \, <br>, <br\>, \r\n, adding two spaces. Nothing worked.

Please provide following details

  1. JiraCLI Version:
    (Version="1.5.1", GitCommit="0e0f82d52ef5a775d2cc662fbe38d9732b9b5c59", CommitDate="2024-01-20T10:48:06+00:00", GoVersion="go1.21.5", Compiler="gc", Platform="linux/amd64")
    
  2. Are you using Jira cloud or on-premise jira server?
      Version:         1001.0.0-SNAPSHOT
      Build Number:    100262
      Deployment Type: Cloud
      Default Locale:  de_DE
    
  3. What operating system are you using? Also mention version.
    Ubuntu bookworm/sid (jammy) x86_64
    Ubuntu 22.04.4 LTS
    
  4. What terminal are you using? Also mention version.
    Tilix
    

To Reproduce

Steps to reproduce the behavior:
see above

Expected behavior
\n should be interpreted as newline

Also seeing this

  1. JiraCLI version
(Version="1.5.1", GitCommit="0e0f82d52ef5a775d2cc662fbe38d9732b9b5c59", CommitDate="2024-01-20T10:48:06+00:00", GoVersion="go1.21.5", Compiler="gc", Platform="darwin/arm64")
  1. Are you using Jira cloud or on-premise jira server?
    Cloud
  2. What operating system
    MacOS Sonoma Version 14.6 (23G80)
  3. Warp

@htammen @SimonHarteDP You need to pass it in a way that allows the shell to expand the character.

The following should work.

jira issue edit issue-001 -b $'Line 1  \nLine 2  \n\nanother line'

Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specified by the ANSI C standard.

Thank you very much @ankitpokhrel. It works.