Re:Hk, The new Heroku Client written in Go
by neya on Wednesday October 23, 2013 @06:33AM
(#6597915)
Thanks for the link to the source, I was asking in general though.
Re:Hk, The new Heroku Client written in Go
by iand on Wednesday October 23, 2013 @06:37AM
(#6597930)
Principle is the same in any language. They all provide a way to parse the arguments passed in. You need to examine those and call the right code based on the argument name. Look for something called ARGV or similar in your language. For example:
node.js - http://nodejs.org/docs/latest/api/process.html#process_proce...
python - http://docs.python.org/2/library/sys.html
ruby - http://www.ruby-doc.org/core-2.0.0/ARGF.html#method-i-argv
Re:Hk, The new Heroku Client written in Go
by chimeracoder on Wednesday October 23, 2013 @09:25AM
(#6598523)
You're looking for the "flag" package, in the standard library: http://golang.org/pkg/flag/
Here's how the hk app does it: https://github.com/heroku/hk/blob/master/main.go#L120
Basically it reads the arguments to the executable and matches them against a built-in list of supported commands and dispatches appropriately.