Posted to tcl by bairui at Wed Jul 18 23:42:36 GMT 2018view raw

  1. proc heredoc {body} {
  2. return [uplevel 1 [list subst -nocommands [join [lmap x [lrange [split $body \n] 1 end-1] {string trim $x}] \n]]]
  3. }
  4.  
  5. proc usage {argv0 argv} {
  6. set usageError [heredoc {
  7. ERROR: [file tail ${argv0}]
  8. \ ?--auto-update?
  9. \ --rolback PIPTYPE PIPPACKAGE
  10. }]
  11. puts $usageError
  12. }
  13.  
  14. usage $argv0 $argv
  15.  

Comments

Posted by bairui at Wed Jul 18 23:54:01 GMT 2018 [text] [code]

# [string trim] feels better than [lrange] proc heredoc {body} { return [string trim [uplevel 1 [list subst -nocommands [join [lmap x [split $body \n] {string trim $x}] \n]]]] }

Posted by CecilWesterhof at Thu Jul 19 05:18:51 GMT 2018 [text] [code]

This generates: ERROR: [file tail /home/cecil/bin/testing.tcl] ?--auto-update? --rolback PIPTYPE PIPPACKAGE While my version generates: ERROR: checkPipPackages.tcl ?--auto-update? --rollback PIPTYPE PIPPACKAGE I also find my version more clear and I find easiness to understand important.

Posted by CecilWesterhof at Thu Jul 19 05:41:20 GMT 2018 [text] [code]

What does what I want: set usageError "ERROR: [file tail ${argv0}] ?--auto-update? --rollback PIPTYPE PIPPACKAGE" Sadly formatting gets lost in replies. :'-(