gli 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +20 -22
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -26,7 +26,9 @@ This will create a basic scaffold project in <tt>./my_proj</tt> with:
|
|
26
26
|
|
27
27
|
=== Example
|
28
28
|
|
29
|
-
This example demonstrates most of the features of GLI
|
29
|
+
This example demonstrates most of the features of GLI.
|
30
|
+
|
31
|
+
This sets you up to use the DSL that GLI defines:
|
30
32
|
|
31
33
|
#!/usr/bin/ruby
|
32
34
|
$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
@@ -35,31 +37,31 @@ This example demonstrates most of the features of GLI
|
|
35
37
|
|
36
38
|
include GLI
|
37
39
|
|
38
|
-
This sets
|
39
|
-
|
40
|
+
This sets a description of your program. This can be as long as you want.
|
40
41
|
|
41
42
|
program_description 'Support program for bootstrapping GLI-based programs'
|
42
43
|
|
43
|
-
This
|
44
|
-
|
44
|
+
This describes a command line switch "-n" that is global to all commands and specified before
|
45
|
+
the command name on the command line.
|
45
46
|
|
46
47
|
desc 'Dry run; don\'t change the disk'
|
47
48
|
switch :n
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
The following describes a command line flag that is global and has a default value of '<tt>.</tt>'. It also
|
51
|
+
specifies a short description of its argument. This is used to print command line help. Note that we
|
52
|
+
have specified two different aliases for this flag. <tt>-r</tt> (because it is listed first) is the default
|
53
|
+
one and <tt>--root</tt> (note two-dash syntax) is also supported. This means that <tt>-r some_dir</tt> and <tt>--root=some_dir</tt> mean
|
54
|
+
the same thing to the application.
|
52
55
|
|
53
56
|
desc 'Root dir in which to create project'
|
57
|
+
long_desc 'This is the location where your project ill be created. A subdirectory named for your project will be created here, and THAT directory will contain the generated files'
|
54
58
|
default_value '.'
|
55
59
|
arg_name 'root_dir'
|
56
60
|
flag [:r,:root]
|
57
61
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
one and <tt>--root</tt> (note two-dash syntax) is also supported. This means that <tt>-r some_dir</tt> and <tt>--root=some_dir</tt> mean
|
62
|
-
the same thing to the application.
|
62
|
+
Here we specify a command. Inside the block we can use the same sorts of things as we did above to define flags
|
63
|
+
and switches specific to the command. These must come after the command name. Also note that we use <tt>arg_name</tt>
|
64
|
+
here to describe the arguments this command accepts.
|
63
65
|
|
64
66
|
desc 'Create a new GLI-based project'
|
65
67
|
arg_name 'project_name [command[ command]*]'
|
@@ -71,9 +73,9 @@ the same thing to the application.
|
|
71
73
|
c.desc 'Overwrite/ignore existing files and directories'
|
72
74
|
c.switch [:force]
|
73
75
|
|
74
|
-
Here we specify
|
75
|
-
|
76
|
-
|
76
|
+
Here we specify the actual actions to take when the command is executed. We define a block that
|
77
|
+
will be given the global options (as a Hash), the command-specific options (as a hash) and the command
|
78
|
+
line arguments
|
77
79
|
|
78
80
|
c.action do |global_options,options,args|
|
79
81
|
if args.length < 1
|
@@ -83,10 +85,6 @@ here to describe the arguments this command accepts.
|
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
86
|
-
Here we specify the actual actions to take when the command is executed. We define a block that
|
87
|
-
will be given the global options (as a Hash), the command-specific options (as a hash) and the command
|
88
|
-
line arguments
|
89
|
-
|
90
88
|
You can also specify some global code to run before, after and on errors:
|
91
89
|
|
92
90
|
pre do |global_options,command,options,args|
|
@@ -109,7 +107,7 @@ Now, we run the program using the arguments the user provided on the command lin
|
|
109
107
|
|
110
108
|
run(ARGV)
|
111
109
|
|
112
|
-
Note that by using <tt>gli init</tt> you can create a shell with all of this already there.
|
110
|
+
Note that by using <tt>gli init</tt> you can create a shell with all of this already there for you.
|
113
111
|
|
114
112
|
What this gives you:
|
115
113
|
|
@@ -121,7 +119,7 @@ What this gives you:
|
|
121
119
|
What this doesn't give you:
|
122
120
|
|
123
121
|
* A way to indicate required flags
|
124
|
-
* A way to indicate a
|
122
|
+
* A way to indicate a required argument or required number of arguments
|
125
123
|
* A way to do default switches to 'true' and therefore accept things like <tt>--no-force</tt>
|
126
124
|
|
127
125
|
== Reference
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Copeland
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-18 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements: []
|
65
65
|
|
66
66
|
rubyforge_project: gli
|
67
|
-
rubygems_version: 1.3.
|
67
|
+
rubygems_version: 1.3.5
|
68
68
|
signing_key:
|
69
69
|
specification_version: 3
|
70
70
|
summary: A Git Like Interface for building command line apps
|