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,649 of 183,477
Downloads: 13,372
Daily
Ranking: 25,458 of 183,470
Downloads: 3
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 | 160,939,746 | yard |
22,686 | 59,037 | inventory |
33,530 | 34,417 | lookout |
34,658 | 32,880 | inventory-rake |
34,988 | 32,467 | inventory-rake-tasks-yard |
51,619 | 19,375 | yard-heuristics |
61,849 | 15,204 | lookout-rake |
Owners
# | Gravatar | Handle |
---|---|---|
1 | now |