Skip to content

Instantly share code, notes, and snippets.

@commuterjoy
Created January 7, 2012 22:54
Show Gist options
  • Save commuterjoy/1576369 to your computer and use it in GitHub Desktop.
Save commuterjoy/1576369 to your computer and use it in GitHub Desktop.
Inline documentation of system commands
# Was trying to figure out a nice way to document oblique system
# commands embedded in a ruby script. I think a nice way is to
# write inline comments then gsub them out and collapse newlines
# before running system().
uri = 'http://example.com'
command = ("curl
-i # print header
-L # follow HTTP 302s
-H 'Cache-control: no-cache'
--cert ~/ca.pem
-k # ignore dodgy certificates
-s
%s" % [uri]).gsub!(/#([^\n]+)|\n/m, '')
puts `#{command}`
@commuterjoy
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment