From: R.. Kumar on 18 Jun 2010 05:22 John Feminella wrote: > > * colorized output That's a trivial issue. All you need is the constants for colors. One example is this file which contains only the constants, nothing else. http://github.com/rkumar/todorb/blob/master/lib/common/colorconstants.rb once you've included it, all you need to do to print red is: text = "hello there" puts "#{RED}#{text}#{CLEAR}" There are constants for colors, attributes, backgrounds etc. -- Posted via http://www.ruby-forum.com/.
From: R.. Kumar on 18 Jun 2010 06:08 Brian Candler wrote: > Rein Henrichs wrote: >> There are probably another dozen tools I haven't found yet or forgot >> didn't mention. > > There's one I can never remember the name of, but is something to do > with prostitutes. Oh yes, it's "trollop". William Morgan, hehe :-) I just did search on github and found this : http://awesome-cli-ruby.heroku.com/ by Dave Copeland. Looks pretty good. I am about to give it a spin. -- Posted via http://www.ruby-forum.com/.
From: R.. Kumar on 18 Jun 2010 12:51 John Feminella wrote: > Does that sort of thing exist? I've noticed there are some apparently > more powerful alternatives like Thor, which is more of a full-stack > scripting framework, and I'm wondering what else might be useful to > take a look at. > > Any and all suggestions would be much appreciated. Thanks! John, I've done a quick comparison of Commander and GLI (git like interface) (see prev post - "awesome cli"). 1. Commander more downloads 3748, gli 1629 (source gemcutter). 2. gli offers scaffolding (generation of dir structure, and a program to start off with containing tasks specified on command line.) commander does not (from what i see), but I've written a similar ruby script to generate the shell program. 3. Commander and gli both offer git like commands and help etc. However, i think gli's command line parsing is not as complete as Commander, which wraps over OptionParser - so if you know Optionparser you can easily use it, and you don't lose what you are used to. Both offer command aliasing, but it seems commander is better. Commander allows you to alias a shortcut to a complex command. 4. Commander wraps over Highline, but i don't see that as a huge issue. You can always use highline if you want separately. Commander also has a decent Progressbar and a terminal-table output formatter. 5. GLI can read your program and generate an rdoc which gives help and options. I don't see that in commander. Not v important, though. 6. GLI generates a directory structure, with gemspec/Rakefile etc, Commander does not. I personally am using jeweler to create a project, so I would rather not have to resolve between these 2. 7. GLI has pre and post handlers and on_error: if needed that can be added in one's script anyway, i think. All in all, after this quick comparison, it seems commander has an edge for *my* needs. Yours could differ. I'll probably start porting my next shell app to ruby in a few days using Commander. HTH. -- Posted via http://www.ruby-forum.com/.
From: R.. Kumar on 18 Jun 2010 12:59 > 2. gli offers scaffolding (generation of dir structure, and a program to > start off with containing tasks specified on command line.) > > commander does not (from what i see), but I've written a similar ruby > script to generate the shell program. > Commander does offer generating a basic program: $ commander init -- Posted via http://www.ruby-forum.com/.
From: R.. Kumar on 20 Jun 2010 06:47 Thomas Sawyer wrote: > > OptionParser generally works fine --even for the items you mention. To > handle subcommands just pop off the top of ARGV before parsing (or for > more advanced use, find the first non-option item). I just found a great example of how you can use subcommands with OptionParser. http://stackoverflow.com/questions/2732894/using-rubys-optionparser-to-parse-sub-commands Note that neither this nor trollop will give you information of subcommands on just typing help. We will have to manually add the help text, but that's a small price to pay for the simplicity of either. I've attached a tiny sample. You can run it as : ruby opt.rb --help ruby opt.rb foo --help ruby opt.rb foo -q Attachments: http://www.ruby-forum.com/attachment/4813/opt.rb -- Posted via http://www.ruby-forum.com/.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: 2010 FIFA World Cup Real Madrid Club football jersey Next: Do I overuse class methods? |