Color ouput with Swift command line tool

后端 未结 6 1934
萌比男神i
萌比男神i 2021-02-01 05:21

I\'m writing a command line tool with Swift and I\'m having trouble displaying colors in my shell. I\'m using the following code:

println(\"\\033[31;32mhey\\033         


        
6条回答
  •  南旧
    南旧 (楼主)
    2021-02-01 05:52

    You can use Rainbow if you don't mind using it as a framework.

    import Rainbow
    print("Red text".red)
    print("Yellow background".onYellow)
    print("Light green text on white background".lightGreen.onWhite)
    

    https://github.com/onevcat/Rainbow

提交回复
热议问题