Skip to content

Instantly share code, notes, and snippets.

@NIA
Created December 25, 2012 15:22
Show Gist options
  • Save NIA/4373705 to your computer and use it in GitHub Desktop.
Save NIA/4373705 to your computer and use it in GitHub Desktop.
Creating help text from map of commands
val commands = ListMap(
"updates" -> "show the last updates",
"help" -> "that is, print this text",
"exit" -> "nuff said, quit the program",
"upupup" -> "Tumc tumc tumc"
)
val helpTabStop = 8
val helpText = "Commands list:\n" + commands.collect({
case (cmd, desc) => cmd + " "*(helpTabStop - cmd.length) + "- " + desc
}).mkString("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment