cmdparse 2.0.5 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +59 -0
- data/Rakefile +94 -124
- data/VERSION +1 -1
- data/doc/{src/about.page → about.page} +8 -12
- data/doc/{src/default.css → default.css} +2 -1
- data/doc/{src/default.template → default.template} +4 -7
- data/doc/download.page +34 -0
- data/doc/index.page +107 -0
- data/doc/{src/logo.png → logo.png} +0 -0
- data/doc/tutorial.page +191 -0
- data/doc/virtual +5 -0
- data/lib/cmdparse.rb +2 -2
- data/lib/cmdparse/wrappers/optparse.rb +1 -1
- data/net.rb +19 -19
- data/setup.rb +861 -607
- data/test/tc_commandhash.rb +96 -0
- metadata +27 -31
- data/README +0 -55
- data/TODO +0 -10
- data/doc/config.yaml +0 -2
- data/doc/plugin/extract.rb +0 -29
- data/doc/src/download.page +0 -34
- data/doc/src/features.page +0 -11
- data/doc/src/index.page +0 -80
- data/doc/src/meta.info +0 -5
- data/doc/src/tutorial.page +0 -177
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d4dca04510d88cd70c3e4591eace794a13f9677a
|
4
|
+
data.tar.gz: db666d2c3f165c61b706fedbe2710bf263003444
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5e81070751e5b4e65e7f88f46c64ab89596e3fcaad7bfd18c36a8e58fb51514c65e863472279ecaaeab0c74a6351ac8fb2738979df855d3986c0457cb99690b2
|
7
|
+
data.tar.gz: 0bf1b2d6807b63aff149cb6cb4ac3101f7422e2cabfd3624a2910f420f6ec458a9a3e46b85fdd4e1b6cbedb170bd4df6576fe6853cccccfb2f1d975826a03bef
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
**cmdparse** - an advanced command line parser using optparse which has support for commands
|
2
|
+
|
3
|
+
Copyright (C) 2004-2014 Thomas Leitner
|
4
|
+
|
5
|
+
## Description
|
6
|
+
|
7
|
+
Some programs use a "command style" command line. Examples for such programs are the "svn" program
|
8
|
+
from Subversion and the "gem" program from Rubygems. The standard Ruby distribution has no library
|
9
|
+
to create programs that use such a command line interface.
|
10
|
+
|
11
|
+
This library, cmdparse, can be used to create such a command line interface. Internally it uses
|
12
|
+
optparse or any other option parser library to parse options and it provides a nice API for
|
13
|
+
specifying commands.
|
14
|
+
|
15
|
+
## License
|
16
|
+
|
17
|
+
GNU LGPLv3 - see COPYING.LESSER for the LGPL and COPYING for the GPL
|
18
|
+
|
19
|
+
## Dependencies
|
20
|
+
|
21
|
+
none
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
The preferred way of installing cmdparse is via RubyGems:
|
26
|
+
|
27
|
+
$ gem install cmdparse
|
28
|
+
|
29
|
+
If you do not have RubyGems installed, but Rake, you can use the following command:
|
30
|
+
|
31
|
+
$ rake install
|
32
|
+
|
33
|
+
If you have neither RubyGems nor Rake, use these commands:
|
34
|
+
|
35
|
+
$ ruby setup.rb config
|
36
|
+
$ ruby setup.rb setup
|
37
|
+
$ ruby setup.rb install
|
38
|
+
|
39
|
+
## Documentation
|
40
|
+
|
41
|
+
You can build the documentation by invoking
|
42
|
+
|
43
|
+
$ rake doc
|
44
|
+
|
45
|
+
This builds the API and the additional documentation. The additional documentation needs webgen
|
46
|
+
>=1.0.0 (webgen.gettalong.org) for building.
|
47
|
+
|
48
|
+
|
49
|
+
## Example
|
50
|
+
|
51
|
+
There is an example of how to use cmdparse in the `net.rb` file.
|
52
|
+
|
53
|
+
|
54
|
+
## Contact
|
55
|
+
|
56
|
+
Author: Thomas Leitner
|
57
|
+
|
58
|
+
* Web: <http://cmdparse.gettalong.org>
|
59
|
+
* e-Mail: <t_leitner@gmx.at>
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
#--
|
4
4
|
# cmdparse: advanced command line parser supporting commands
|
5
|
-
# Copyright (C) 2004-
|
5
|
+
# Copyright (C) 2004-2014 Thomas Leitner
|
6
6
|
#
|
7
7
|
# This file is part of cmdparse.
|
8
8
|
#
|
@@ -19,18 +19,22 @@
|
|
19
19
|
#
|
20
20
|
#++
|
21
21
|
|
22
|
-
|
23
22
|
begin
|
24
23
|
require 'rubygems'
|
25
|
-
require '
|
24
|
+
require 'rubygems/package_task'
|
26
25
|
rescue Exception
|
27
26
|
nil
|
28
27
|
end
|
29
28
|
|
29
|
+
begin
|
30
|
+
require 'webgen/page'
|
31
|
+
rescue LoadError
|
32
|
+
end
|
33
|
+
|
30
34
|
require 'rake/clean'
|
31
35
|
require 'rake/packagetask'
|
32
|
-
require 'rake/rdoctask'
|
33
36
|
require 'rake/testtask'
|
37
|
+
require 'rdoc/task'
|
34
38
|
|
35
39
|
# General actions ##############################################################
|
36
40
|
|
@@ -38,167 +42,133 @@ $:.unshift 'lib'
|
|
38
42
|
require 'cmdparse'
|
39
43
|
|
40
44
|
PKG_NAME = "cmdparse"
|
41
|
-
PKG_VERSION = CmdParse::VERSION.join(
|
45
|
+
PKG_VERSION = CmdParse::VERSION.join('.')
|
42
46
|
PKG_FULLNAME = PKG_NAME + "-" + PKG_VERSION
|
43
47
|
|
44
|
-
|
48
|
+
# End user tasks ################################################################
|
45
49
|
|
46
50
|
# The default task is run if rake is given no explicit arguments.
|
47
51
|
|
48
|
-
desc "Default Task"
|
52
|
+
desc "Default Task (does testing)"
|
49
53
|
task :default => :test
|
50
54
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
desc "Prepares for installation"
|
55
|
-
task :prepare do
|
55
|
+
desc "Installs the package #{PKG_NAME} using setup.rb"
|
56
|
+
task :install do
|
56
57
|
ruby "setup.rb config"
|
57
58
|
ruby "setup.rb setup"
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
desc "Installs the package #{PKG_NAME}"
|
62
|
-
task :install => [:prepare]
|
63
|
-
task :install do
|
64
59
|
ruby "setup.rb install"
|
65
60
|
end
|
66
61
|
|
67
|
-
|
68
62
|
task :clean do
|
69
63
|
ruby "setup.rb clean"
|
70
64
|
end
|
71
65
|
|
72
|
-
|
73
|
-
|
66
|
+
Rake::TestTask.new do |test|
|
67
|
+
test.test_files = FileList['test/tc_*.rb']
|
74
68
|
end
|
75
69
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
70
|
+
if defined?(Webgen)
|
71
|
+
CLOBBER << "htmldoc"
|
72
|
+
CLOBBER << "webgen-tmp"
|
73
|
+
desc "Builds the documentation"
|
74
|
+
task :htmldoc do
|
80
75
|
sh "webgen"
|
81
76
|
end
|
82
77
|
end
|
83
78
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
79
|
+
if defined? RDoc::Task
|
80
|
+
RDoc::Task.new do |rdoc|
|
81
|
+
rdoc.rdoc_dir = 'htmldoc/rdoc'
|
82
|
+
rdoc.title = PKG_NAME
|
83
|
+
rdoc.main = 'CmdParse::CommandParser'
|
84
|
+
rdoc.options << '--line-numbers'
|
85
|
+
rdoc.rdoc_files.include('lib')
|
86
|
+
end
|
89
87
|
end
|
90
88
|
|
89
|
+
if defined?(Webgen) && defined?(RDoc::Task)
|
90
|
+
desc "Build the whole user documentation"
|
91
|
+
task :doc => [:rdoc, :htmldoc]
|
92
|
+
end
|
91
93
|
|
92
94
|
# Developer tasks ##############################################################
|
93
95
|
|
96
|
+
namespace :dev do
|
97
|
+
|
98
|
+
PKG_FILES = FileList.new( [
|
99
|
+
'setup.rb',
|
100
|
+
'COPYING',
|
101
|
+
'COPYING.LESSER',
|
102
|
+
'README.md',
|
103
|
+
'Rakefile',
|
104
|
+
'net.rb',
|
105
|
+
'VERSION',
|
106
|
+
'lib/**/*.rb',
|
107
|
+
'doc/**/*',
|
108
|
+
'test/*'
|
109
|
+
])
|
94
110
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
'README',
|
101
|
-
'Rakefile',
|
102
|
-
'net.rb',
|
103
|
-
'VERSION',
|
104
|
-
'lib/**/*.rb',
|
105
|
-
'doc/**/*'
|
106
|
-
]) do |fl|
|
107
|
-
fl.exclude( /\bsvn\b/ )
|
108
|
-
fl.exclude( 'doc/output' )
|
109
|
-
end
|
111
|
+
CLOBBER << "VERSION"
|
112
|
+
file 'VERSION' do
|
113
|
+
puts "Generating VERSION file"
|
114
|
+
File.open('VERSION', 'w+') {|file| file.write(PKG_VERSION + "\n")}
|
115
|
+
end
|
110
116
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
117
|
+
Rake::PackageTask.new('cmdparse', PKG_VERSION) do |pkg|
|
118
|
+
pkg.need_tar = true
|
119
|
+
pkg.need_zip = true
|
120
|
+
pkg.package_files = PKG_FILES
|
121
|
+
end
|
115
122
|
|
116
|
-
|
123
|
+
if defined? Gem
|
124
|
+
spec = Gem::Specification.new do |s|
|
117
125
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
126
|
+
#### Basic information
|
127
|
+
s.name = PKG_NAME
|
128
|
+
s.version = PKG_VERSION
|
129
|
+
s.summary = "Advanced command line parser supporting commands"
|
130
|
+
s.description = <<-EOF
|
122
131
|
cmdparse provides classes for parsing commands on the command line; command line options
|
123
132
|
are parsed using optparse or any other option parser implementation. Programs that use
|
124
133
|
such command line interfaces are, for example, subversion's 'svn' or Rubygem's 'gem' program.
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
s.author = "Thomas Leitner"
|
143
|
-
s.email = "t_leitner@gmx.at"
|
144
|
-
s.homepage = "http://cmdparse.rubyforge.org"
|
145
|
-
s.rubyforge_project = "cmdparse"
|
146
|
-
end
|
147
|
-
|
148
|
-
task :package => [:generateFiles]
|
149
|
-
task :generateFiles do |t|
|
150
|
-
File.open('VERSION', 'w+') do |file| file.write( PKG_VERSION + "\n" ) end
|
151
|
-
end
|
134
|
+
EOF
|
135
|
+
s.license = 'LGPLv3'
|
136
|
+
|
137
|
+
#### Dependencies, requirements and files
|
138
|
+
s.files = PKG_FILES.to_a
|
139
|
+
s.require_path = 'lib'
|
140
|
+
s.autorequire = 'cmdparse'
|
141
|
+
|
142
|
+
#### Documentation
|
143
|
+
s.has_rdoc = true
|
144
|
+
s.rdoc_options = ['--line-numbers', '--main', 'CmdParse::CommandParser']
|
145
|
+
|
146
|
+
#### Author and project details
|
147
|
+
s.author = "Thomas Leitner"
|
148
|
+
s.email = "t_leitner@gmx.at"
|
149
|
+
s.homepage = "http://cmdparse.gettalong.org"
|
150
|
+
end
|
152
151
|
|
153
|
-
|
152
|
+
Gem::PackageTask.new(spec) do |pkg|
|
153
|
+
pkg.need_zip = true
|
154
|
+
pkg.need_tar = true
|
155
|
+
end
|
154
156
|
|
155
|
-
Rake::GemPackageTask.new( spec ) do |pkg|
|
156
|
-
pkg.need_zip = true
|
157
|
-
pkg.need_tar = true
|
158
157
|
end
|
159
158
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
sh "scp -r * gettalong@rubyforge.org:/var/www/gforge-projects/cmdparse/"
|
166
|
-
end
|
167
|
-
|
168
|
-
|
169
|
-
# Misc tasks ###################################################################
|
170
|
-
|
171
|
-
|
172
|
-
def count_lines( filename )
|
173
|
-
lines = 0
|
174
|
-
codelines = 0
|
175
|
-
open( filename ) do |f|
|
176
|
-
f.each do |line|
|
177
|
-
lines += 1
|
178
|
-
next if line =~ /^\s*$/
|
179
|
-
next if line =~ /^\s*#/
|
180
|
-
codelines += 1
|
159
|
+
if defined?(Gem)
|
160
|
+
desc "Upload the release to Rubygems"
|
161
|
+
task :publish_files => [:package] do
|
162
|
+
sh "gem push pkg/cmdparse-#{PKG_VERSION}.gem"
|
163
|
+
puts 'done'
|
181
164
|
end
|
182
165
|
end
|
183
|
-
[lines, codelines]
|
184
|
-
end
|
185
166
|
|
167
|
+
if defined?(Webgen) && defined?(Gem) && defined?(Rake::RDocTask)
|
168
|
+
desc "Release cmdparse version " + PKG_VERSION
|
169
|
+
task :release => [:clobber, :package, :publish_files]
|
170
|
+
end
|
186
171
|
|
187
|
-
def show_line( msg, lines, loc )
|
188
|
-
printf "%6s %6s %s\n", lines.to_s, loc.to_s, msg
|
189
172
|
end
|
190
173
|
|
191
|
-
|
192
|
-
desc "Show statistics"
|
193
|
-
task :statistics do
|
194
|
-
total_lines = 0
|
195
|
-
total_code = 0
|
196
|
-
show_line( "File Name", "Lines", "LOC" )
|
197
|
-
SRC_RB.each do |fn|
|
198
|
-
lines, codelines = count_lines fn
|
199
|
-
show_line( fn, lines, codelines )
|
200
|
-
total_lines += lines
|
201
|
-
total_code += codelines
|
202
|
-
end
|
203
|
-
show_line( "Total", total_lines, total_code )
|
204
|
-
end
|
174
|
+
task :clobber => ['dev:clobber']
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.6
|
@@ -1,9 +1,9 @@
|
|
1
1
|
---
|
2
2
|
title: About
|
3
|
-
|
4
|
-
|
3
|
+
in_menu: true
|
4
|
+
sort_info: 2
|
5
5
|
---
|
6
|
-
|
6
|
+
## About `cmdparse`
|
7
7
|
|
8
8
|
Some new programs use a "command style" command line. Examples for such programs are the "svn"
|
9
9
|
program from Subversion and the "gem" program from Rubygems. The standard Ruby distribution has no
|
@@ -15,14 +15,10 @@ specifying commands and subcommands.
|
|
15
15
|
|
16
16
|
A typical command line for a program which uses commands looks like this:
|
17
17
|
|
18
|
-
|
19
|
-
$ net --verbose ipaddr add 192.168.0.1 193.150.0.1
|
20
|
-
</pre>
|
18
|
+
$ net --verbose ipaddr add 192.168.0.1 193.150.0.1
|
21
19
|
|
20
|
+
## Author
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
*
|
26
|
-
* Web: "http://cmdparse.rubyforge.org":http://cmdparse.rubyforge.org
|
27
|
-
* e-Mail: "t_leitner@gmx.at":mailto:t_leitner@gmx.at
|
28
|
-
* GPG Key-Id: 0xD942E7F6
|
22
|
+
* **Thomas Leitner**
|
23
|
+
* Web: <http://cmdparse.gettalong.org>
|
24
|
+
* e-Mail: <mailto:t_leitner@gmx.at>
|
@@ -20,23 +20,20 @@
|
|
20
20
|
</div>
|
21
21
|
|
22
22
|
<div id="headerbar" class="bar">
|
23
|
-
<span class="left">Navbar: {
|
24
|
-
<span class="right">Language: {langbar: }</span>
|
23
|
+
<span class="left">Navbar: {breadcrumb_trail: }</span>
|
25
24
|
<div style="clear:both"></div>
|
26
25
|
</div>
|
27
26
|
|
28
27
|
<div id="menu">
|
29
|
-
{menu:}
|
28
|
+
{menu: {options: {mi: {in_menu: true}, sort: true}}}
|
30
29
|
</div>
|
31
30
|
|
32
31
|
<div id="body">
|
33
|
-
|
32
|
+
<webgen:block name="content" />
|
34
33
|
</div>
|
35
34
|
|
36
35
|
<div id="footer" class="bar">
|
37
|
-
<a href="http://
|
38
|
-
<a href="http://jigsaw.w3.org/css-validator/check/referer"><img src="{resource: w3c-valid-css}" alt="Valid CSS!" height="31" width="88" /></a>
|
39
|
-
<a href="http://webgen.rubyforge.org"><img src="{resource: webgen-generated}" alt="Generated by webgen" height="31" width="88"/></a> on <b>{date: }</b>
|
36
|
+
Generated by <a href="http://webgen.gettalong.org">webgen</a> on <b>{date: }</b>
|
40
37
|
</div>
|
41
38
|
</div>
|
42
39
|
</body>
|
data/doc/download.page
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
---
|
2
|
+
title: Download & Installation
|
3
|
+
in_menu: true
|
4
|
+
sort_info: 4
|
5
|
+
---
|
6
|
+
## Download
|
7
|
+
|
8
|
+
The newest version of cmdparse can be downloaded from [Rubygems] or the [cmdparse Github
|
9
|
+
page][github]!
|
10
|
+
|
11
|
+
[Rubygems]: http://rubygems.org/gems/cmdparse
|
12
|
+
[github]: http://github.com/gettalong/cmdparse
|
13
|
+
|
14
|
+
|
15
|
+
## Dependencies
|
16
|
+
|
17
|
+
This library has *no* dependencies.
|
18
|
+
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
The preferred way of installing cmdparse is via RubyGems:
|
23
|
+
|
24
|
+
$ gem install cmdparse
|
25
|
+
|
26
|
+
If you do not have RubyGems installed, but Rake, you can use the following command:
|
27
|
+
|
28
|
+
$ rake install
|
29
|
+
|
30
|
+
If you have neither RubyGems nor Rake, use these commands:
|
31
|
+
|
32
|
+
$ ruby setup.rb config
|
33
|
+
$ ruby setup.rb setup
|
34
|
+
$ ruby setup.rb install
|