[ANN] CoolOptions 1.0.3 has been released

  • Thread starter Nathaniel Talbott
  • Start date
N

Nathaniel Talbott

CoolOptions version 1.0.3 has been released!

http://cooloptions.rubyforge.org/

CoolOptions is a simple wrapper around optparse that provides less
configuration and more convenience for doing command-line option
handling.

As a huge fan of optparse due to its flexibility, self-documenting
nature, and ease of use, I nevertheless found myself doing almost the
exact same thing with it over and over again, and decided to write a
thin wrapper around it to handle the common cases. Thus CoolOptions
was born. An example of using it:

$ cat new_rails_project
require 'cooloptions'

options = CoolOptions.parse!("[options] PROJECTNAME") do |o|
o.on "repository URL", "Remote subversion repository."
o.on "svk", "Use svk.", true
o.on "project-path PATH", "Root of project workspaces.",
File.expand_path("~/svk")
o.on "l)repository-path PATH", "Remote repository path.", "/"
o.on "mirror-path SVKPATH", "SVK mirror path.", "//"
o.on "local-pa(t)h SVKPATH", "SVK local path.",
"//local"
o.on "create-structure", "Create trunk/tags/branches structure.", true
o.on "finish", "Prep and commit the new project.", true

o.after do |r|
r.project_path = File.expand_path(r.project_path)
o.error("Invalid path.") unless File.exist?(r.project_path)
r.project_name = ARGV.shift
o.error("Project name is required.") unless r.project_name
o.error("Project name is too funky.") unless /^\w+$/ =~ r.project_name
end
end

p options.svk
p options.project_path
p options.repository
p options.create_structure
p options.project_name

$ ./new_rails_project --no-svk -r
http://terralien.com/svn/terralien/ myproject
false
"/Users/ntalbott/svk"
"http://terralien.com/svn/terralien/"
true
"myproject"

More details can be found in the documentation, available at the URL above.

Feedback is welcome, and I hope you find CoolOptions useful and
enjoyable to use!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top