ruby_cli 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +14 -13
- data/Rakefile +8 -0
- data/lib/ruby_cli.rb +6 -3
- data/test/test_ruby_cli.rb +13 -0
- metadata +5 -3
data/README.rdoc
CHANGED
@@ -10,15 +10,16 @@ License:: Distributed under the same terms as Ruby
|
|
10
10
|
programswith a command line interface (CLI) which follows the Unix Philosophy
|
11
11
|
design method outlined in http://www.faqs.org/docs/artu/ch01s06.html.
|
12
12
|
|
13
|
-
Currently, RubyCLI is short and simple. It uses Ruby's core
|
13
|
+
Currently, RubyCLI is short and simple. It uses Ruby's core
|
14
|
+
optparse[http://ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html] library.
|
14
15
|
|
15
16
|
= Design
|
16
17
|
|
17
18
|
What does a command line application library need to do?
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
1. Provide a user interface (UI)
|
20
|
+
* Process options (use Ruby's Option Parser)
|
21
|
+
* Process arguments
|
22
|
+
2. Pass options and arguments as parameters to other functions defined in libraries or other executables.
|
22
23
|
|
23
24
|
What does a command line application library need not do?
|
24
25
|
1. A command line application does not need to validate options or arguments. Libraries or other executables should do this.
|
@@ -32,14 +33,14 @@ gem install ruby_cli
|
|
32
33
|
There are other tools out there which can be used to write command line
|
33
34
|
applications.
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
1. clamp[http://github.com/mdub/clamp]
|
37
|
+
* I don't like to learn new DSLs
|
38
|
+
2. optparse[http://ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html]
|
39
|
+
* This library uses this to parse options.
|
40
|
+
3. Thor[http://github.com/wycats/thor]
|
41
|
+
* It does not try to follow the Unix Philosophy.
|
42
|
+
4. Clip[http://clip.rubyforge.org/]
|
43
|
+
* OptionParser already exists.
|
43
44
|
|
44
45
|
= Usage
|
45
46
|
|
data/Rakefile
ADDED
data/lib/ruby_cli.rb
CHANGED
@@ -104,13 +104,16 @@ module RubyCLI
|
|
104
104
|
# Performs post-parse processing on options
|
105
105
|
# For instance, some options may be mutually exclusive
|
106
106
|
# Redefine if you need to process options.
|
107
|
-
def process_options() true end
|
107
|
+
def process_options() return true end
|
108
108
|
|
109
109
|
# Redefine if you need to process options.
|
110
|
-
def process_arguments() true end
|
110
|
+
def process_arguments() return true end
|
111
111
|
|
112
112
|
# Application logic
|
113
|
-
def command
|
113
|
+
def command
|
114
|
+
raise "This method should be overwritten."
|
115
|
+
return 0
|
116
|
+
end
|
114
117
|
|
115
118
|
def output_help(exit_code)
|
116
119
|
puts @opt_parser
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Martin Velez
|
@@ -31,6 +31,8 @@ files:
|
|
31
31
|
- lib/ruby_cli.rb
|
32
32
|
- README.rdoc
|
33
33
|
- bin/hello_world
|
34
|
+
- test/test_ruby_cli.rb
|
35
|
+
- Rakefile
|
34
36
|
has_rdoc: true
|
35
37
|
homepage: http://github.com/martinvelez/ruby_cli
|
36
38
|
licenses: []
|