Categories: None [Edit]
ame
Ame
Ame provides a simple command-line interface API for Ruby¹. It can be used
to provide both simple interfaces like that of ‹rm›² and complex ones like
that of ‹git›³. It uses Ruby’s own classes, methods, and argument lists to
provide an interface that is both simple to use from the command-line side
and from the Ruby side. The provided command-line interface is flexible and
follows commond standards for command-line processing.
¹ See http://ruby-lang.org/
² See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm.html
³ See http://git-scm.com/docs/
§ Usage
Let’s begin by looking at two examples, one where we mimic the POSIX¹
command-line interface to the ‹rm› command. Looking at the entry² in the
standard, ‹rm› takes the following options:
= -f. = Do not prompt for confirmation.
= -i. = Prompt for confirmation.
= -R. = Remove file hierarchies.
= -r. = Equivalent to /-r/.
It also takes the following arguments:
= FILE. = A pathname or directory entry to be removed.
And actually allows one or more of these /FILE/ arguments to be given.
We also note that the ‹rm› command is described as a command to “remove
directory entries”.
¹ See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html
² See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm.html
Let’s turn this specification into one using Ame’s API. We begin by adding
a flag for each of the options listed above:
class Rm < Ame::Root
flag 'f', '', false, 'Do not prompt for confirmation'
flag 'i', '', nil, 'Prompt for confirmation' do |options|
options['f'] = false
end
flag 'R', '', false, 'Remove file hierarchies'
flag 'r', '', nil, 'Equivalent to -R' do |options|
options['r'] = true
end
A flag¹ is a boolean option that doesn’t take an argument. Each flag gets
a short and long name, where an empty name means that there’s no
...
Total
Ranking: 67,556 of 183,107
Downloads: 13,309
Daily
Ranking: 86,038 of 183,092
Downloads: 0
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
Rank | Downloads | Name |
---|
Depends on
Rank | Downloads | Name |
---|---|---|
224 | 158,681,269 | yard |
22,630 | 58,827 | inventory |
33,429 | 34,289 | lookout |
34,575 | 32,744 | inventory-rake |
34,879 | 32,346 | inventory-rake-tasks-yard |
51,549 | 19,282 | yard-heuristics |
61,713 | 15,140 | lookout-rake |
Owners
# | Gravatar | Handle |
---|---|---|
1 | now |