subcommand 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,15 @@
1
- = subcommand
1
+
2
+ = Subcommand
2
3
 
3
4
  A tiny wrapper over ruby's awesome OptionParser (standard) which gives easy facility of subcommands.
4
5
  It has a similar interface to git and prints subcommands summary as well.
5
6
 
6
- == Features:
7
+ Options parsers are lazy-loaded thanks to a suggestion and sample code by Robert Klemme on ruby-forum.org.
8
+ If your program already uses OptionParser, then one merely needs to add a line above each option declaration -- no rewriting required since all OptionParser syntax is valid syntax for `subcommand`.
9
+
10
+ This wrapper adds the `description` attr to what OptionParser already provides.
11
+
12
+ == Features
7
13
 
8
14
  1. subcommands using all of OptionParser's features
9
15
  2. aliases for subcommands
@@ -59,6 +65,9 @@ Assuming a program "prog" with subcommands "del" and "add"
59
65
  # aliases init and create
60
66
  command :init, :create do |opts| ...
61
67
 
68
+ alias_command :zoo, 'foo' , '-f'
69
+ alias_command :bar, 'baz' , 'ruby.txt'
70
+
62
71
  3. call opt_parse()
63
72
 
64
73
  == Sample Output
@@ -93,6 +102,19 @@ Assuming a program "prog" with subcommands "del" and "add"
93
102
 
94
103
  Or, copy into your lib directory and require (see source for sample usage)
95
104
 
105
+ == Testing
106
+
107
+ This comes with a bunch of test cases, that I think cover all cases including printing help
108
+ for aliases.
109
+
110
+ make test
111
+
112
+ You should have no errors. The test cases are in the **tests** folder.
113
+
114
+ == RDOC
115
+
116
+ http://subcommand.rubyforge.org/doc/
117
+
96
118
  == Note on Patches/Pull Requests
97
119
 
98
120
  * Fork the project.
data/TODO CHANGED
@@ -1 +1 @@
1
- Add aliases
1
+ add test1 and test2.rb in test cases
@@ -136,7 +136,7 @@ module Subcommands
136
136
  @global.order!
137
137
  cmd = ARGV.shift
138
138
  if cmd
139
- $stderr.puts "Command: #{cmd}, args:#{ARGV}, #{@commands.keys} "
139
+ #$stderr.puts "Command: #{cmd}, args:#{ARGV}, #{@commands.keys} "
140
140
  sc = @commands[cmd]
141
141
  #puts "sc: #{sc}: #{@commands}"
142
142
  unless sc
@@ -151,7 +151,7 @@ module Subcommands
151
151
  # else if help <command> then print its help GIT style (3)
152
152
  if !ARGV.empty? && cmd == "help"
153
153
  cmd = ARGV.shift
154
- $stderr.puts " 110 help #{cmd}"
154
+ #$stderr.puts " 110 help #{cmd}"
155
155
  sc = @commands[cmd]
156
156
  # if valid command print help, else print global help
157
157
  unless sc
@@ -180,14 +180,14 @@ module Subcommands
180
180
  end
181
181
  def _check_alias cmd
182
182
  alas = @aliases[cmd]
183
- $stderr.puts "195 alas: #{alas} "
183
+ #$stderr.puts "195 alas: #{alas} "
184
184
  if alas
185
185
  case alas
186
186
  when Array
187
187
  cmd = alas.shift
188
- $stderr.puts "Array cmd: #{cmd} "
188
+ #$stderr.puts "Array cmd: #{cmd} "
189
189
  ARGV.unshift alas.shift unless alas.empty?
190
- $stderr.puts "ARGV #{ARGV} "
190
+ #$stderr.puts "ARGV #{ARGV} "
191
191
  else
192
192
  cmd = alas
193
193
  end
@@ -0,0 +1,65 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{subcommand}
8
+ s.version = "1.0.4"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Rahul Kumar"]
12
+ s.date = %q{2010-06-24}
13
+ s.description = %q{Subcommand and alias facility for command line programs with elegant help printing}
14
+ s.email = %q{sentinel.1879@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc",
18
+ "TODO"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".gitignore",
23
+ "LICENSE",
24
+ "Makefile",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/subcommand.rb",
29
+ "subcommand.gemspec",
30
+ "tests/Makefile",
31
+ "tests/README",
32
+ "tests/aggregate-results.sh",
33
+ "tests/recreate.sh",
34
+ "tests/rtest2.sh",
35
+ "tests/t0001-main.sh",
36
+ "tests/t0002-subcomm.sh",
37
+ "tests/t0003-inv_comm.sh",
38
+ "tests/t0004-subcomm.sh",
39
+ "tests/t0005-alias_goo.sh",
40
+ "tests/t0006-goo_opt.sh",
41
+ "tests/t0007-bar_baz.sh",
42
+ "tests/t0008-boo_zoo.sh",
43
+ "tests/test-lib.sh"
44
+ ]
45
+ s.homepage = %q{http://github.com/rkumar/subcommand}
46
+ s.rdoc_options = ["--charset=UTF-8"]
47
+ s.require_paths = ["lib"]
48
+ s.rubyforge_project = %q{subcommand}
49
+ s.rubygems_version = %q{1.3.6}
50
+ s.summary = %q{A tiny wrapper over OptionParser giving simple, elegant subcommand facility}
51
+
52
+ if s.respond_to? :specification_version then
53
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
+ s.specification_version = 3
55
+
56
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
57
+ s.add_development_dependency(%q<yard>, [">= 0"])
58
+ else
59
+ s.add_dependency(%q<yard>, [">= 0"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<yard>, [">= 0"])
63
+ end
64
+ end
65
+
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 3
9
- version: 1.0.3
8
+ - 4
9
+ version: 1.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Rahul Kumar
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-21 00:00:00 +05:30
17
+ date: 2010-06-24 00:00:00 +05:30
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -48,8 +48,7 @@ files:
48
48
  - Rakefile
49
49
  - VERSION
50
50
  - lib/subcommand.rb
51
- - test/helper.rb
52
- - test/test_subcommand.rb
51
+ - subcommand.gemspec
53
52
  - tests/Makefile
54
53
  - tests/README
55
54
  - tests/aggregate-results.sh
@@ -95,6 +94,5 @@ rubygems_version: 1.3.6
95
94
  signing_key:
96
95
  specification_version: 3
97
96
  summary: A tiny wrapper over OptionParser giving simple, elegant subcommand facility
98
- test_files:
99
- - test/helper.rb
100
- - test/test_subcommand.rb
97
+ test_files: []
98
+
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
-
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'subcommand'
8
-
9
- class Test::Unit::TestCase
10
- end
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestSubcommand < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end