cmdparse 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,80 +1,185 @@
1
1
  ------------------------------------------------------------------------
2
- r10 | thomas | 2004-09-27 18:46:38 +0200 (Mon, 27 Sep 2004) | 1 line
2
+ r242 | thomas | 2005-04-13 13:42:24 +0200 (Wed, 13 Apr 2005) | 1 line
3
3
  Changed paths:
4
- M /trunk/Rakefile
5
- M /trunk/doc/src/download.fragment
4
+ M /trunk/cmdparse/README
5
+
6
+
7
+ ------------------------------------------------------------------------
8
+ r241 | thomas | 2005-04-13 13:41:16 +0200 (Wed, 13 Apr 2005) | 3 lines
9
+ Changed paths:
10
+ M /trunk/cmdparse/README
11
+ M /trunk/cmdparse/Rakefile
12
+ M /trunk/cmdparse/TODO
13
+ A /trunk/cmdparse/logo.svg
14
+ M /trunk/cmdparse/test.rb
15
+
16
+ * added logo.svg
17
+ * adapted test.rb
18
+ * minor modifcation in Rakefile
19
+ ------------------------------------------------------------------------
20
+ r240 | thomas | 2005-04-13 13:40:39 +0200 (Wed, 13 Apr 2005) | 4 lines
21
+ Changed paths:
22
+ M /trunk/cmdparse/lib/cmdparse.rb
23
+
24
+ * added NoCommandGivenError class
25
+ * renamed class InvalidCommand to InvalidCommandError
26
+ * added option for specifying default command
27
+ * bumped version number to 1.0.1
28
+ ------------------------------------------------------------------------
29
+ r239 | thomas | 2005-04-13 13:38:04 +0200 (Wed, 13 Apr 2005) | 3 lines
30
+ Changed paths:
31
+ M /trunk/cmdparse/doc/src/default.css
32
+ M /trunk/cmdparse/doc/src/default.template
33
+ M /trunk/cmdparse/doc/src/download.page
34
+ M /trunk/cmdparse/doc/src/features.page
35
+ M /trunk/cmdparse/doc/src/index.page
36
+ A /trunk/cmdparse/doc/src/logo.png
37
+ M /trunk/cmdparse/doc/src/meta.info
38
+
39
+ * added logo
40
+ * converted pages to use textile markup
41
+ * added news section on homepage
42
+ ------------------------------------------------------------------------
43
+ r238 | thomas | 2005-04-13 12:06:31 +0200 (Wed, 13 Apr 2005) | 2 lines
44
+ Changed paths:
45
+ M /trunk/cmdparse/doc/src/default.css
46
+ M /trunk/cmdparse/doc/src/default.template
47
+ D /trunk/cmdparse/doc/src/download.fragment
48
+ A /trunk/cmdparse/doc/src/download.page (from /trunk/cmdparse/doc/src/download.fragment:235)
49
+ D /trunk/cmdparse/doc/src/features.fragment
50
+ A /trunk/cmdparse/doc/src/features.page (from /trunk/cmdparse/doc/src/features.fragment:235)
51
+ D /trunk/cmdparse/doc/src/index.fragment
52
+ A /trunk/cmdparse/doc/src/index.page (from /trunk/cmdparse/doc/src/index.fragment:235)
53
+ A /trunk/cmdparse/doc/src/meta.info (from /trunk/cmdparse/doc/src/metainfo.backing:235)
54
+ D /trunk/cmdparse/doc/src/metainfo.backing
55
+
56
+ * updated documentation pages to webgen 0.3.1
57
+ * added new default.template and css file
58
+ ------------------------------------------------------------------------
59
+ r235 | thomas | 2005-04-13 11:17:35 +0200 (Wed, 13 Apr 2005) | 1 line
60
+ Changed paths:
61
+ A /trunk/cmdparse (from /trunk/commandparser:165)
62
+
63
+ * renamed commandparser dir to cmdparse
64
+ ------------------------------------------------------------------------
65
+ r165 | thomas | 2005-01-13 17:33:02 +0100 (Thu, 13 Jan 2005) | 1 line
66
+ Changed paths:
67
+ D /temp
68
+ A /trunk (from /temp:163)
69
+
70
+ add finally arrived at the destination
71
+ ------------------------------------------------------------------------
72
+ r163 | thomas | 2005-01-13 17:31:39 +0100 (Thu, 13 Jan 2005) | 1 line
73
+ Changed paths:
74
+ A /temp
75
+ A /temp/commandparser (from /trunk/commandparser/trunk:162)
76
+ A /temp/programs (from /trunk/miscprograms/trunk:162)
77
+ A /temp/rubyquiz (from /trunk/rubyquiz:162)
78
+ A /temp/webgen (from /trunk/webgen/trunk:162)
79
+ A /temp/xmlresume2x (from /trunk/xmlresume2x/trunk:162)
80
+ D /trunk/commandparser/trunk
81
+ D /trunk/miscprograms/trunk
82
+ D /trunk/rubyquiz
83
+ D /trunk/webgen/trunk
84
+ D /trunk/webgen/versions/webgen-0.1.0
85
+ D /trunk/webgen/versions/webgen-0.2.0
86
+ D /trunk/xmlresume2x/trunk
87
+ D /trunk/xmlresume2x/versions/xmlresume2x-0.1.0
88
+ D /trunk/xmlresume2x/versions/xmlresume2x-0.2.0
89
+ D /trunk/xmlresume2x/versions/xmlresume2x-0.2.1
90
+ A /versions
91
+ A /versions/webgen-0.1.0 (from /trunk/webgen/versions/webgen-0.1.0:162)
92
+ A /versions/webgen-0.2.0 (from /trunk/webgen/versions/webgen-0.2.0:162)
93
+ A /versions/xmlresume2x-0.1.0 (from /trunk/xmlresume2x/versions/xmlresume2x-0.1.0:162)
94
+ A /versions/xmlresume2x-0.2.0 (from /trunk/xmlresume2x/versions/xmlresume2x-0.2.0:162)
95
+ A /versions/xmlresume2x-0.2.1 (from /trunk/xmlresume2x/versions/xmlresume2x-0.2.1:162)
96
+
97
+ moved stuff around and around
98
+ ------------------------------------------------------------------------
99
+ r14 | thomas | 2004-09-30 17:54:54 +0200 (Thu, 30 Sep 2004) | 2 lines
100
+ Changed paths:
101
+ M /trunk/commandparser/trunk/lib/cmdparse.rb
102
+ M /trunk/commandparser/trunk/test.rb
103
+
104
+ * added the directory lib to the loadpath of test.rb
105
+ * the "--help" and "-h" global options now take a command as optional argument
106
+ ------------------------------------------------------------------------
107
+ r12 | thomas | 2004-09-27 18:46:38 +0200 (Mon, 27 Sep 2004) | 1 line
108
+ Changed paths:
109
+ M /trunk/commandparser/trunk/Rakefile
110
+ M /trunk/commandparser/trunk/doc/src/download.fragment
6
111
 
7
112
  * corrected an error in the <Download> page and in the Rakefile
8
113
  ------------------------------------------------------------------------
9
- r8 | thomas | 2004-09-27 18:22:39 +0200 (Mon, 27 Sep 2004) | 3 lines
114
+ r10 | thomas | 2004-09-27 18:22:39 +0200 (Mon, 27 Sep 2004) | 3 lines
10
115
  Changed paths:
11
- M /trunk/Rakefile
12
- M /trunk/doc/src/default.template
13
- M /trunk/lib/cmdparse.rb
116
+ M /trunk/commandparser/trunk/Rakefile
117
+ M /trunk/commandparser/trunk/doc/src/default.template
118
+ M /trunk/commandparser/trunk/lib/cmdparse.rb
14
119
 
15
120
  * changed version to 1.0.0
16
121
  * updated Rakefile
17
122
  * minor change in documentation template
18
123
  ------------------------------------------------------------------------
19
- r7 | thomas | 2004-09-27 18:11:36 +0200 (Mon, 27 Sep 2004) | 1 line
124
+ r9 | thomas | 2004-09-27 18:11:36 +0200 (Mon, 27 Sep 2004) | 1 line
20
125
  Changed paths:
21
- M /trunk/README
22
- M /trunk/Rakefile
23
- A /trunk/doc/src/default.css
24
- A /trunk/doc/src/default.template
25
- A /trunk/doc/src/download.fragment
26
- A /trunk/doc/src/features.fragment
27
- A /trunk/doc/src/index.fragment
28
- A /trunk/doc/src/metainfo.backing
29
- M /trunk/lib/cmdparse.rb
126
+ M /trunk/commandparser/trunk/README
127
+ M /trunk/commandparser/trunk/Rakefile
128
+ A /trunk/commandparser/trunk/doc/src/default.css
129
+ A /trunk/commandparser/trunk/doc/src/default.template
130
+ A /trunk/commandparser/trunk/doc/src/download.fragment
131
+ A /trunk/commandparser/trunk/doc/src/features.fragment
132
+ A /trunk/commandparser/trunk/doc/src/index.fragment
133
+ A /trunk/commandparser/trunk/doc/src/metainfo.backing
134
+ M /trunk/commandparser/trunk/lib/cmdparse.rb
30
135
 
31
136
  * added some documentation to the doc folder
32
137
  ------------------------------------------------------------------------
33
- r6 | thomas | 2004-09-27 17:45:02 +0200 (Mon, 27 Sep 2004) | 2 lines
138
+ r8 | thomas | 2004-09-27 17:45:02 +0200 (Mon, 27 Sep 2004) | 2 lines
34
139
  Changed paths:
35
- A /trunk/doc/src
36
- M /trunk/lib/cmdparse.rb
37
- M /trunk/test.rb
140
+ A /trunk/commandparser/trunk/doc/src
141
+ M /trunk/commandparser/trunk/lib/cmdparse.rb
142
+ M /trunk/commandparser/trunk/test.rb
38
143
 
39
144
  * added VersionCommand class
40
145
  * added example to rdoc documentation
41
146
  ------------------------------------------------------------------------
42
- r5 | thomas | 2004-09-26 18:27:54 +0200 (Sun, 26 Sep 2004) | 3 lines
147
+ r7 | thomas | 2004-09-26 18:27:54 +0200 (Sun, 26 Sep 2004) | 3 lines
43
148
  Changed paths:
44
- A /trunk/COPYING
45
- A /trunk/README
46
- A /trunk/Rakefile
47
- D /trunk/cmdparse.rb
48
- A /trunk/doc
49
- A /trunk/lib
50
- A /trunk/lib/cmdparse.rb (from /trunk/cmdparse.rb:4)
51
- A /trunk/setup.rb
149
+ A /trunk/commandparser/trunk/COPYING
150
+ A /trunk/commandparser/trunk/README
151
+ A /trunk/commandparser/trunk/Rakefile
152
+ D /trunk/commandparser/trunk/cmdparse.rb
153
+ A /trunk/commandparser/trunk/doc
154
+ A /trunk/commandparser/trunk/lib
155
+ A /trunk/commandparser/trunk/lib/cmdparse.rb (from /trunk/commandparser/trunk/cmdparse.rb:6)
156
+ A /trunk/commandparser/trunk/setup.rb
52
157
 
53
158
  * added standard files: COPYING, README, Rakefile, setup.rb
54
159
  * moved cmdparse.rb into lib directory
55
160
  * added documentation
56
161
  ------------------------------------------------------------------------
57
- r4 | thomas | 2004-09-23 17:19:11 +0200 (Thu, 23 Sep 2004) | 3 lines
162
+ r6 | thomas | 2004-09-23 17:19:11 +0200 (Thu, 23 Sep 2004) | 3 lines
58
163
  Changed paths:
59
- M /trunk/TODO
60
- M /trunk/cmdparse.rb
61
- M /trunk/test.rb
164
+ M /trunk/commandparser/trunk/TODO
165
+ M /trunk/commandparser/trunk/cmdparse.rb
166
+ M /trunk/commandparser/trunk/test.rb
62
167
 
63
168
  * remove error checking in main part so that error fall threw
64
169
  * added new commands to OptionParser class to get unchanged values
65
170
  * added <good> behaviour for usage and banner lines
66
171
  ------------------------------------------------------------------------
67
- r3 | thomas | 2004-09-22 20:16:29 +0200 (Wed, 22 Sep 2004) | 1 line
172
+ r5 | thomas | 2004-09-22 20:16:29 +0200 (Wed, 22 Sep 2004) | 1 line
68
173
  Changed paths:
69
- A /trunk/TODO
70
- A /trunk/cmdparse.rb
71
- A /trunk/test.rb
174
+ A /trunk/commandparser/trunk/TODO
175
+ A /trunk/commandparser/trunk/cmdparse.rb
176
+ A /trunk/commandparser/trunk/test.rb
72
177
 
73
178
  * initial import
74
179
  ------------------------------------------------------------------------
75
- r1 | thomas | 2004-09-22 20:15:42 +0200 (Wed, 22 Sep 2004) | 1 line
180
+ r3 | thomas | 2004-09-22 20:15:42 +0200 (Wed, 22 Sep 2004) | 1 line
76
181
  Changed paths:
77
- A /trunk
182
+ A /trunk/commandparser/trunk
78
183
 
79
184
 
80
185
  ------------------------------------------------------------------------
data/README CHANGED
@@ -36,12 +36,12 @@ You can build the documentation by invoking
36
36
  $ rake doc
37
37
 
38
38
  This builds the API and the additional documentation. The additional documentation needs webgen
39
- (webgen.rubyforge.org) for building.
39
+ >=0.3.2 (webgen.rubyforge.org) for building.
40
40
 
41
41
 
42
42
  = Example
43
43
 
44
- There is an example of how to use cmdparse in the +test+ directory.
44
+ There is an example of how to use cmdparse in the +test.rb+ file.
45
45
 
46
46
 
47
47
  = Contact
data/Rakefile CHANGED
@@ -71,7 +71,7 @@ CLOBBER << "doc/output"
71
71
  desc "Builds the documentation"
72
72
  task :doc => [:rdoc] do
73
73
  Dir.chdir("doc")
74
- sh "webgen -V 4"
74
+ sh "webgen -V 3"
75
75
  Dir.chdir("..")
76
76
  end
77
77
 
@@ -154,14 +154,6 @@ else
154
154
 
155
155
  end
156
156
 
157
-
158
- desc "Creates a tag in the repository"
159
- task :tag do
160
- repositoryPath = File.dirname( $1 ) if `svn info` =~ /^URL: (.*)$/
161
- fail "Tag already created in repository " if /#{PKG_FULLNAME}/ =~ `svn ls #{repositoryPath}/versions`
162
- sh "svn cp -m 'Created version #{PKG_FULLNAME}' #{repositoryPath}/trunk #{repositoryPath}/versions/#{PKG_FULLNAME}"
163
- end
164
-
165
157
  desc "Upload documentation to homepage"
166
158
  task :uploaddoc => [:doc] do
167
159
  Dir.chdir('doc/output')
data/TODO CHANGED
@@ -1,5 +1,7 @@
1
1
 
2
-
3
2
  ---- DONE ----
4
3
 
5
4
  * define banner in a common way (like option parser), maybe use the one from option parser
5
+ * raise NoCommandGivenError when no command was given
6
+ * ability to specify default command (used when no command was given)
7
+ * add order,order!,... methods to mimic optparse
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
data/doc/src/default.css CHANGED
@@ -1,85 +1,84 @@
1
- html {
2
- margin: 0px 5%;
3
- background-color: #eee;
4
- }
1
+ /*
2
+ #5CB85C -> background
3
+ #408040 -> headings
4
+ #CFE6CF -> code
5
+ #30BF30 -> other
6
+ */
5
7
 
6
8
  body {
7
- margin: 0px;
8
- padding: 0px;
9
- background-color: #fff;
9
+ margin: 0px 2em;
10
10
  font-size: 12px;
11
11
  font-family: Verdana, Arial, Helvetica;
12
+ border: 1px solid black;
13
+ color: black;
12
14
  }
13
15
 
14
- /* General layout of the page */
16
+ h1, h2, h3, h4, h5 { color: #408040}
17
+
18
+ a:visited { color: #408040; }
19
+ a { color: #5CB85C; }
20
+ .bar a { color: white }
21
+ .bar a:visited { color: white }
15
22
 
16
- #header, #footer {
17
- width: 100%;
18
- background-color: #58b;
19
- color: #fff;
23
+ #all { background-color: #CFE6CF; }
24
+
25
+ #header {
26
+ border-bottom: 1px solid black;
27
+ padding: 1ex;
28
+ background-color: #5CB85C;
29
+ }
30
+ #header img {
31
+ padding-right: 5em;
32
+ }
33
+ #header h1 {
34
+ margin: 0ex;
35
+ font-size: 300%;
36
+ font-style: italic;
37
+ font-weight: normal;
38
+ color: white;
39
+ }
40
+
41
+ , #headerbar { border-bottom: 1px solid black; }
42
+ #footer { border-top: 1px solid black; }
43
+
44
+ #body {
45
+ margin-left: 250px;
46
+ margin-right: 20px;
47
+ padding: 10px;
20
48
  }
21
49
 
22
50
  #menu {
23
51
  float: left;
24
52
  width: 230px;
25
- padding: 20px 0px 0px 20px;
26
- border: 3px solid #58b;
53
+ padding: 20px 0px 0px 2px;
27
54
  }
28
55
 
29
- #body {
30
- margin-left: 250px;
31
- padding: 20px;
32
- }
33
-
34
- #footer {
56
+ .bar {
35
57
  clear: both;
36
- padding: 5px 0px;
58
+ padding: 3px;
37
59
  text-align: center;
38
- }
39
-
40
-
41
- /* styling the header */
42
-
43
- #headerbar {
44
- width: 100%;
45
60
  font-size: 90%;
61
+ background-color: #30BF30;
46
62
  }
47
63
 
48
- span#navbar, span#languages {
49
- padding: 3px;
50
- width: 45%;
64
+ .left, .right {
65
+ padding: 0px 1em;
51
66
  }
52
67
 
53
- span#navbar {
68
+ .left {
54
69
  float: left;
55
70
  text-align: left;
56
71
  }
57
72
 
58
- span#languages {
73
+ .right {
59
74
  float: right;
60
75
  text-align: right;
61
76
  }
62
77
 
63
- div#header h1, h2 {
64
- margin: 0px;
65
- padding: 15px 50px 0px;
66
-
67
- font-size: 300%;
68
- font-style: italic;
69
- font-weight: normal;
70
- }
71
-
72
- div#header h2 {
73
- padding-top: 0px;
74
- padding-bottom: 15px;
75
- font-size: 100%;
76
- }
77
-
78
78
  /* styling the menu */
79
79
 
80
80
  #menu a {
81
81
  text-decoration: none;
82
- color: #b55;
83
82
  font-weight: bold;
84
83
  font-size: 130%;
85
84
  }
@@ -89,10 +88,7 @@
89
88
  }
90
89
 
91
90
  #menu .webgen-menuitem-selected {
92
- border-left: 3px solid #58b;
93
- }
94
-
95
- #menu .webgen-submenu {
91
+ border-left: 3px solid #408040;
96
92
  }
97
93
 
98
94
  #menu ul {
@@ -114,24 +110,37 @@
114
110
 
115
111
  /* styling the content */
116
112
 
117
- div.section {
118
- margin-bottom: 30px;
119
- }
120
-
121
- h2.section_header {
113
+ h2 {
122
114
  padding: 0px;
123
- border-bottom: 3px double #8b5;
124
-
125
115
  letter-spacing: 0.2em;
126
116
  font-size: 150%;
127
117
  font-weight: bold;
128
- color: #8b5;
118
+ border-bottom: 1px solid #408040;
129
119
  }
130
120
 
131
- pre.webgen-file {
121
+ .webgen-file {
132
122
  padding-left: 10px;
133
123
  margin: 0px 10px;
134
- border-left: 3px solid #8b5;
124
+ border-left: 3px solid #5CB85C;
125
+ }
126
+
127
+ .webgen-picture {
128
+ text-align: center;
129
+ }
130
+
131
+ .webgen-picture img {
132
+ border: 1px solid black;
133
+ }
134
+
135
+ .webgen-gallery {
136
+ text-align: center;
137
+ }
138
+
139
+ .webgen-gallery table {
140
+ width: 100%;
135
141
  }
136
142
 
137
- }
143
+ .webgen-gallery table td{
144
+ text-align: center;
145
+ border: 1px solid black;
146
+ }
@@ -1,32 +1,41 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{lang:}">
4
4
  <head>
5
- <title>CommandParser: {title: }</title>
5
+ <title>CommandParser: {title:}</title>
6
6
  <link href="{relocatable: default.css}" rel="stylesheet" />
7
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
8
  </head>
8
9
  <body>
9
- <div id="header">
10
- <h1>{title: }</h1>
11
- <h2>cmdparse: an advanced command line parser using optparse which supports commands</h2>
12
- <div id="headerbar">
13
- <span id="navbar">{navbar: }</span>
14
- <span id="languages">{lang: }</span>
15
- <div style="clear: both; border-top: 1px solid #58b"></div>
10
+ <div id="all">
11
+
12
+ <div id="header">
13
+ <table>
14
+ <tr>
15
+ <td><img src="{relocatable: logo.png}" alt="Logo" title="Logo" /></td>
16
+ <td><h1>CommandParser<span style="font-size: 60%"> - advanced command line parser which supports commands</span></h1>
17
+ </td>
18
+ </tr>
19
+ </table>
16
20
  </div>
17
- </div>
18
21
 
19
- <div id="menu">
20
- {menu: }
21
- </div>
22
+ <div id="headerbar" class="bar">
23
+ <span class="left">Navbar: {navbar: }</span>
24
+ <span class="right">Language: {langbar: }</span>
25
+ <div style="clear:both"></div>
26
+ </div>
22
27
 
23
- <div id="body">
24
- {content: }
25
- </div>
28
+ <div id="menu">
29
+ {menu:}
30
+ </div>
26
31
 
27
- <div id="footer">
28
- generated with <em><b><a href="http://webgen.rubyforge.org">webgen</a></b></em> on <b>{date: }</b>
29
- </div>
32
+ <div id="body">
33
+ {content:}
34
+ </div>
30
35
 
36
+ <div id="footer" class="bar">
37
+ generated with <em><b><a href="http://webgen.rubyforge.org"><em><b>webgen</b></em></a></b></em> on <b>{date: }</b>
38
+ </div>
39
+ </div>
31
40
  </body>
32
41
  </html>
@@ -0,0 +1,34 @@
1
+ ---
2
+ title: Download &amp; Installation
3
+ inMenu: true
4
+ menuOrder: 3
5
+ ---
6
+ h2. Download
7
+
8
+ The newest version of cmdparse can be downloaded from Rubyforge.
9
+
10
+ Homepage: <a href="http://cmdparse.rubyforge.org">cmdparse.rubyforge.org</a><br />
11
+ Download: <a href="http://rubyforge.org/frs/?group_id=396">http://rubyforge.org/frs/?group_id=396</a>
12
+
13
+ h2. Dependencies
14
+
15
+ optparse - part of the standard ruby distribution, so nothing to do here
16
+
17
+ h2. Installation
18
+
19
+ You can use the standard way to install cmdparse:
20
+ <pre>
21
+ $ ruby setup.rb config
22
+ $ ruby setup.rb setup
23
+ $ ruby setup.rb install
24
+ </pre>
25
+
26
+ Or you could use Rake and substitute the above commands with this:
27
+ <pre>
28
+ $ rake install
29
+ </pre>
30
+
31
+ Or you could install cmdparse the "GEM way":
32
+ <pre>
33
+ $ gem install cmdparse
34
+ </pre>
@@ -0,0 +1,11 @@
1
+ ---
2
+ title: Features
3
+ inMenu: true
4
+ menuOrder: 5
5
+ ---
6
+ h2. Feature list
7
+
8
+ * Based upon the standard library @optparse@
9
+ * Default help and version commands
10
+ * Each command is implemented via a class
11
+ * As easy to use as @optparse@ itself!
@@ -0,0 +1,34 @@
1
+ ---
2
+ title: HomePage
3
+ inMenu: true
4
+ directoryName: CommandParser
5
+ menuOrder: 1
6
+ ---
7
+ h2. Welcome
8
+
9
+ ... to the homepage of _*CommandParser*_, an advanced command line parser.
10
+
11
+ Have a look around the site!
12
+
13
+ h2. News
14
+
15
+ *cmdparse 1.0.1 released!!!*
16
+
17
+ Changes:
18
+
19
+ * Improved HelpCommand: the global options -h and --help take an optional command name now
20
+ * Possibility to define a default command which is used when no command was specified
21
+ * A @NoCommandGivenError@ is thrown when no command on the CLI and no default command was specified
22
+
23
+ h2. Description
24
+
25
+ Some new programs use a "command style" command line. Examples for such programs are the "svn"
26
+ program from Subversion and the "gem" program from Rubygems. The standard Ruby distribution has no
27
+ library to create programs that use such a command line interface.
28
+
29
+ This library, cmdparse, can be used to create such a command line interface. Internally it uses
30
+ optparse to parse options and it provides a nice API for specifying commands.
31
+
32
+ h2. And so
33
+
34
+ ... have fun!
data/doc/src/logo.png ADDED
Binary file
data/doc/src/meta.info ADDED
@@ -0,0 +1,6 @@
1
+ api.html:
2
+ en:
3
+ dest: rdoc/index.html
4
+ title: API Reference
5
+ menuOrder: 7
6
+ inMenu: true
data/lib/cmdparse.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: cmdparse.rb 8 2004-09-27 16:22:39Z thomas $
4
+ # $Id: cmdparse.rb 240 2005-04-13 11:40:39Z thomas $
5
5
  #
6
6
  # cmdparse: an advanced command line parser using optparse which supports commands
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -91,7 +91,7 @@ end
91
91
  # opt.on("-r", "--require TEST", "Require the TEST")
92
92
  # opt.on("--delay N", Integer, "Delay test for N seconds before executing")
93
93
  # end
94
- # cmd.add_command TestCommand.new
94
+ # cmd.add_command TestCommand.new, true # sets this command as default command
95
95
  # cmd.add_command CommandParser::HelpCommand.new
96
96
  # cmd.add_command CommandParser::VersionCommand.new
97
97
  # cmd.parse!( ARGV )
@@ -99,11 +99,16 @@ end
99
99
  class CommandParser
100
100
 
101
101
  # The version of the command parser
102
- VERSION = [1, 0, 0]
102
+ VERSION = [1, 0, 1]
103
103
 
104
104
  # This error is thrown when an invalid command is encountered.
105
- class InvalidCommand < OptionParser::ParseError
106
- const_set(:Reason, 'invalid command'.freeze)
105
+ class InvalidCommandError < OptionParser::ParseError
106
+ const_set( :Reason, 'invalid command'.freeze )
107
+ end
108
+
109
+ # This error is thrown when no command was given and no default command was specified.
110
+ class NoCommandGivenError < OptionParser::ParseError
111
+ const_set( :Reason, 'no command given'.freeze )
107
112
  end
108
113
 
109
114
  # Base class for the commands. This class implements all needed methods so that it can be used by
@@ -171,8 +176,8 @@ class CommandParser
171
176
 
172
177
  def init( commandParser )
173
178
  commandParser.options do |opt|
174
- opt.on_tail( "-h", "--help", "Show help" ) do
175
- execute( commandParser, [] )
179
+ opt.on_tail( "-h", "--help [command]", "Show help" ) do |cmd|
180
+ execute( commandParser, cmd.nil? ? [] : [cmd] )
176
181
  end
177
182
  end
178
183
  end
@@ -262,11 +267,12 @@ class CommandParser
262
267
  end
263
268
 
264
269
  # Holds the registered commands
265
- attr_reader :commands
270
+ attr_reader :commands
266
271
 
267
272
  def initialize
268
273
  @options = OptionParser.new
269
274
  @commands = {}
275
+ @default = nil
270
276
  end
271
277
 
272
278
  # If called with a block, this method yields the global options of the +CommandParser+. If no
@@ -279,24 +285,41 @@ class CommandParser
279
285
  end
280
286
  end
281
287
 
282
- # Adds a command to the command list.
283
- def add_command( command )
288
+ # Adds a command to the command list. If the optional parameter +default+ is true, then this
289
+ # command is used when no command is specified on the command line.
290
+ def add_command( command, default = false )
284
291
  @commands[command.name] = command
292
+ @default = command.name if default
285
293
  command.init( self )
286
294
  end
287
295
 
296
+ # Calls +parse+ - implemented to mimic OptionParser
297
+ def permute( args ); parse( args ); end
298
+ # Calls +parse!+ - implemented to mimic OptionParser
299
+ def permute!( args ); parse!( args ); end
300
+ # Calls +parse+ - implemented to mimic OptionParser
301
+ def order( args ); parse( args ); end
302
+ # Calls +parse!+ - implemented to mimic OptionParser
303
+ def order!( args ); parse!( args ); end
304
+
288
305
  # see CommandParser#parse!
289
- def parse( args )
290
- parse!( args.dup )
291
- end
306
+ def parse( args ); parse!( args.dup ); end
292
307
 
293
308
  # Parses the given argument. First it tries to parse global arguments if given. After that the
294
309
  # command name is analyzied and the options for the specific commands parsed. After that the
295
310
  # command is executed by invoking its +execute+ method.
296
311
  def parse!( args )
297
312
  @options.order!( args )
298
- command = args.shift || 'no command given'
299
- raise InvalidCommand.new( command ) unless commands.include?( command )
313
+ command = args.shift
314
+ if command.nil?
315
+ if @default.nil?
316
+ raise NoCommandGivenError
317
+ else
318
+ command = @default
319
+ end
320
+ else
321
+ raise InvalidCommandError.new( command ) unless commands.include?( command )
322
+ end
300
323
  commands[command].options.permute!( args ) unless commands[command].options.nil?
301
324
  commands[command].execute( self, args )
302
325
  end
metadata CHANGED
@@ -1,18 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.1
2
+ rubygems_version: 0.8.4
3
3
  specification_version: 1
4
4
  name: cmdparse
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2004-09-27
6
+ version: 1.0.1
7
+ date: 2005-04-13
8
8
  summary: An advanced command line parser using optparse which supports commands
9
9
  require_paths:
10
10
  - lib
11
- author: Thomas Leitner
12
11
  email: t_leitner@gmx.at
13
12
  homepage: cmdparse.rubyforge.org
14
13
  rubyforge_project: cmdparse
15
- description: "cmdparse extends the default option parser 'optparse' by adding support for commands. Programs that use such command line interfaces are, for example, subversion's 'svn' or Rubygem's 'gem' program."
14
+ description: "cmdparse extends the default option parser 'optparse' by adding support for
15
+ commands. Programs that use such command line interfaces are, for example,
16
+ subversion's 'svn' or Rubygem's 'gem' program."
16
17
  autorequire:
17
18
  default_executable:
18
19
  bindir: bin
@@ -25,6 +26,8 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
26
  version: 0.0.0
26
27
  version:
27
28
  platform: ruby
29
+ authors:
30
+ - Thomas Leitner
28
31
  files:
29
32
  - setup.rb
30
33
  - TODO
@@ -35,12 +38,13 @@ files:
35
38
  - VERSION
36
39
  - lib/cmdparse.rb
37
40
  - doc/src
38
- - doc/src/metainfo.backing
39
41
  - doc/src/default.css
40
- - doc/src/index.fragment
42
+ - doc/src/features.page
43
+ - doc/src/index.page
44
+ - doc/src/download.page
41
45
  - doc/src/default.template
42
- - doc/src/features.fragment
43
- - doc/src/download.fragment
46
+ - doc/src/meta.info
47
+ - doc/src/logo.png
44
48
  test_files: []
45
49
  rdoc_options:
46
50
  - "--line-numbers"
@@ -1,32 +0,0 @@
1
- <div class="section">
2
- <h2 class="section_header">Download</h2>
3
- <p>The newest version of cmdparse can be downloaded from Rubyforge.</p>
4
- <p>Homepage: <a href="http://cmdparse.rubyforge.org">cmdparse.rubyforge.org</a><br />
5
- Download: <a href="http://rubyforge.org/frs/?group_id=396">http://rubyforge.org/frs/?group_id=396</a>
6
- </p>
7
- </div>
8
-
9
- <div class="section">
10
- <h2 class="section_header">Dependencies</h2>
11
- <p>optparse - part of the standard ruby distribution, so nothing to do here</p>
12
- </div>
13
-
14
- <div class="section">
15
- <h2 class="section_header">Installation</h2>
16
- You can use the standard way to install cmdparse:
17
- <pre>
18
- $ ruby setup.rb config
19
- $ ruby setup.rb setup
20
- $ ruby setup.rb install
21
- </pre>
22
-
23
- Or you could use Rake and substitute the above commands with this:
24
- <pre>
25
- $ rake install
26
- </pre>
27
-
28
- Or you could install cmdparse the "GEM way":
29
- <pre>
30
- $ gem install cmdparse
31
- </pre>
32
- </div>
@@ -1,8 +0,0 @@
1
- <div class="section">
2
- <h2 class="section_header">Feature list</h2>
3
- <ul>
4
- <li>Based upon the standard library <code>optparse</code></li>
5
- <li>Each command is implemented via a class</li>
6
- <li>As easy to use as <code>optparse</code> itself</li>
7
- </ul>
8
- </div>
@@ -1,21 +0,0 @@
1
- <div class="section">
2
- <h2 class="section_header">Welcome</h2>
3
- <p>... to the homepage of <i><b>cmdparse</b></i>, an advanced command line parser.</p>
4
- <p>Have a look around the site!</p>
5
- </div>
6
-
7
- <div class="section">
8
- <h2 class="section_header">Description</h2>
9
- <p>Some new programs use a "command style" command line. Examples for such programs are the "svn"
10
- program from Subversion and the "gem" program from Rubygems. The standard Ruby distribution has no
11
- library to create programs that use such a command line interface.</p>
12
-
13
- <p>This library, cmdparse, can be used to create such a command line interface. Internally it uses
14
- optparse to parse options and it provides a nice API for specifying commands.</p>
15
-
16
- </div>
17
-
18
- <div class="section">
19
- <h2 class="section_header">And so ...</h2>
20
- <p>... have fun!</p>
21
- </div>
@@ -1,25 +0,0 @@
1
- index.html:
2
- en:
3
- title: Home
4
- inMenu: true
5
- directoryName: CommandParser
6
- menuOrder: 1
7
-
8
- download.html:
9
- en:
10
- title: Download &amp; Installation
11
- inMenu: true
12
- menuOrder: 3
13
-
14
- features.html:
15
- en:
16
- title: Features
17
- inMenu: true
18
- menuOrder: 5
19
-
20
- api.html:
21
- en:
22
- dest: rdoc/index.html
23
- title: API Reference
24
- menuOrder: 7
25
- inMenu: true