• Stars
    star
    49
  • Rank 565,710 (Top 12 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 13 years ago
  • Updated about 12 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Command-line Ruby Utilities Shipped as Classes

Quickl

Description

Quickl helps you create commandline programs as simply as:

#
# Short description here
#
# SYNOPSIS
#   Usage: ...
#
# OPTIONS:
# #{summarized_options}
#
# DESCRIPTION
#   Long description here...
#
class SimpleCommand < Quickl::Command(__FILE__, __LINE__)

  # install options below
  options do |opt|
    # _opt_ is an OptionParser instance
  end
  
  # install the code to run the command
  def execute(args)
    # _args_ are non-option command line parameters
  end

end

Running them as simply as:

SimpleCommand.run(ARGV)

From simple command to complex delegator (ala 'git [--version] [--help] COMMAND [cmd options] ARGS...'), Quickl provides (or aims at providing) the following features:

  • Simple command creations via simple classes
  • Delegator commands and categories via ruby namespaces and naming conventions
  • Command help and documentation provided through rdoc
  • Command options via standard OptionParser
  • Error handling trought special blocks, assertions methods and dedicated Error classes
  • Unit/spec testing of commands, as they are part of the software

Install

sudo gem install quickl

Then?

Try this:

# have a look at options
quickl --help

# generate a hello.rb single command
quickl --layout=single --options=help,version hello > hello.rb

# test your command
ruby hello.rb --help
ruby hello.rb --version
ruby hello.rb bob

# see what has been generated
cat hello.rb

Additional examples (see examples folder):

Related work

A few other gems similarly provide tools to generate commandline app.

  • https://github.com/wycats/thor provides a way to bundle command line utilities as class methods. It also provides an alternative to Rake and therefore sees commands as tasks. It is more mature that quickl but is also a bit more opinionated IMHO. If you want one command by class, use quickl; one command by method, go for thor instead.
  • https://github.com/mdub/clamp is very similar to quickl as well, even more similar than thor in fact. Clamp supports subcommands and options (not through OptionParser, though). It does not have the quickl's auto-documentation feature, but has an automatic --help. I would say that Clamp is maybe a bit lighter and 'straight to the point' than quickl, but also more magic and opinionated.
  • See also: http://trollop.rubyforge.org/, http://clip.rubyforge.org/

Version policy

Until version 1.0.0, moditications of public interfaces increase the minor version, while other changes increase the tiny version. After version 1.0.0, same changes will affect major and minor versions, respectively.

0.1.0 -> 0.1.1    # enhancements and private API changes
0.1.0 -> 0.2.0    # broken API on public interfaces

Public interfaces are:

  • Quickl::Command and Quickl::Delegator calls
  • DSL methods used in "subclasses" built by Quickl::Command and Quickl::Delegator
  • RDoc -> command line documentation recognizers (synopsis, overview, documentation, ...)
  • Naming conventions (module <-> command conversions)
  • Default reactions to errors (Quickl::Help, Quickl::Exit, ...)

Until version 1.0.0, to preserve your application from hurting changes you should require quickl as follows:

gem 'quickl', '~> 0.2.0'    # Assuming current version is 0.2.xx
require 'quickl'

More Repositories

1

viiite

An alternative to ruby Benchmark
Ruby
56
star
2

nib.js

Node.js packaging for the Browser
Ruby
26
star
3

myrrha

The missing coercion framework for Ruby
Ruby
25
star
4

pdf-toolkit

A ruby interface to pdftk
Ruby
23
star
5

noe

Noe is a simple, general-purpose and extensible skeleton generator from project templates
Ruby
21
star
6

cudd

CU Decision Diagram Package (CUDD, unofficial mirror)
C
17
star
7

summaryse

Array#summaryse
Ruby
14
star
8

stamina

Automaton and Induction Tools Written in Ruby
Ruby
7
star
9

dbagile

Agile SQL databases and tools for database administrators
Ruby
6
star
10

sbyc

Adding Specialization By Constraint to the Ruby type system
Ruby
6
star
11

yargi

Yet Another Ruby Graph Implementation
Ruby
5
star
12

plwords

http://plwords.herokuapp.com/
Ruby
5
star
13

jsonml-rb

JsonML, in ruby
Ruby
3
star
14

rel.js

A Relational Database System for the Browser
JavaScript
3
star
15

anagram

Reusable grammars, parsers and rewriting tools
Ruby
3
star
16

waw

A simple and different web framework for ruby
Ruby
3
star
17

agora

Agile Goal-Oriented Requirement Acquisition
Ruby
3
star
18

clipreasy

Clinical Processes Made Easy
Ruby
2
star
19

rubyrel

Ruby and the Relational Model
Ruby
2
star
20

rqp2

The Relational Query Puzzle Platform
Ruby
2
star
21

cudd-rb

A ruby bridge to the CU Decision Diagram package (CUDD)
Ruby
2
star
22

logbook

A medical log book
JavaScript
1
star
23

rea

The Research Exploring Assistant
Ruby
1
star
24

be.uclouvain.jail

Java Automaton and Induction Tookit
Java
1
star
25

stamina-contest-website

Source code of the Stamina Website
Ruby
1
star
26

rubybench

Benchmarking rubies
1
star
27

alf.noe

A noe template for alf sub-modules
Ruby
1
star
28

db-bench

Let's benchmark different database approaches
1
star
29

wAw.js

web Another way, a web framework in javascript/coffeescript
Ruby
1
star
30

pipas-persister

The Persistent component of the PIPAS medical scheduler
Ruby
1
star
31

fp101x

Haskell
1
star
32

blambeau.github.com

blambeau's github pages
1
star
33

passsafe

Keep hashed passwords a secure way, e.g. in (local) storage
JavaScript
1
star
34

rubygem.noe

A .noe template for creating ruby gems
Ruby
1
star
35

sqlize

Non-OO manipulation of SQL schemas...
Ruby
1
star
36

websync

End-user oriented website synchronization & deployment
Ruby
1
star
37

polygon

A sinatra-powered web framework for mostly static websites
Ruby
1
star