Posted to tcl by bairui at Wed Jul 18 23:42:36 GMT 2018view pretty
proc heredoc {body} { return [uplevel 1 [list subst -nocommands [join [lmap x [lrange [split $body \n] 1 end-1] {string trim $x}] \n]]] } proc usage {argv0 argv} { set usageError [heredoc { ERROR: [file tail ${argv0}] \ ?--auto-update? \ --rolback PIPTYPE PIPPACKAGE }] puts $usageError } usage $argv0 $argv
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. :'-(