Created
February 6, 2018 13:13
-
-
Save reitzig/5b7bf7934b827594273850bdfa6a1d32 to your computer and use it in GitHub Desktop.
Transforms a (long) string into a Swift multi-line string literal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
if ARGV.count < 2 | |
puts "Usage: swift-mlsl.rb line-length string" | |
Process.exit(0) | |
end | |
blocksize = ARGV[0].to_i | |
parts = ARGV[1].scan(/.{1,#{blocksize}}/) | |
puts "\"\"\"\n" + parts.join("\\\n") + "\n\"\"\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment