subcommand 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +74 -74
- data/VERSION +1 -1
- data/subcommand.gemspec +15 -18
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30b9e0db36c45a59dab2d993ba1d9e9efa2a73d972e568f2ea847dfe36ac142a
|
4
|
+
data.tar.gz: f68575069d08d882a91291c4222f65b7a090078d39cda3456836cf0373161249
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec27f7b55bb7344cdec562ae8574b61ce1042c169526fb9aa4f010d537a9ada17955e7d04473b43329c26319b5ace740ab2fbf6203ef7d336c0357d4c9c9524b
|
7
|
+
data.tar.gz: 36bbbbadaf547a2105be5c0af81dd23bf15d488b82140e7879134eede4c3e7a3ac352b8f00809a187f5e3481d07b8315517aa8e6e394a0f2c706596bf52569ab
|
data/README.rdoc
CHANGED
@@ -18,129 +18,129 @@ This wrapper adds the `description` attr to what OptionParser already provides.
|
|
18
18
|
e.g
|
19
19
|
Assuming a program "prog" with subcommands "del" and "add"
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
prog help
|
22
|
+
prog --help
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
prog help del
|
25
|
+
prog del --help
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
prog del --force file.a
|
28
|
+
prog --verbose del --force file.a
|
29
29
|
|
30
30
|
== Examples
|
31
31
|
|
32
|
-
|
32
|
+
if a program has subcommands foo and baz
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
ruby subcommand.rb help
|
35
|
+
ruby subcommand.rb --help
|
36
|
+
ruby subcommand.rb help foo
|
37
|
+
ruby subcommand.rb foo --help
|
38
|
+
ruby subcommand.rb baz --quiet "some text"
|
39
|
+
ruby subcommand.rb --verbose foo --force file.zzz
|
40
40
|
|
41
41
|
== STEPS
|
42
42
|
|
43
|
-
|
43
|
+
1. define global_options (optional)
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
global_options do |opts|
|
46
|
+
opts.banner = "Usage: subcommand.rb [options] [subcommand [options]]"
|
47
|
+
opts.description = "Stupid program that does something"
|
48
|
+
opts.separator ""
|
49
|
+
opts.separator "Global options are:"
|
50
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
51
|
+
options[:verbose] = v
|
52
|
+
end
|
53
|
+
end
|
54
54
|
|
55
55
|
2. define commands using command(). Send multiple names for aliases.
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
57
|
+
command :foo do |opts|
|
58
|
+
opts.banner = "Usage: foo [options]"
|
59
|
+
opts.description = "desc for foo"
|
60
|
+
opts.on("-f", "--[no-]force", "force action") do |v|
|
61
|
+
options[:force] = v
|
62
|
+
end
|
63
|
+
end
|
64
64
|
|
65
|
-
|
66
|
-
|
65
|
+
# aliases init and create
|
66
|
+
command :init, :create do |opts| ...
|
67
67
|
|
68
|
-
|
69
|
-
|
68
|
+
alias_command :zoo, 'foo' , '-f'
|
69
|
+
alias_command :bar, 'baz' , 'ruby.txt'
|
70
70
|
|
71
|
-
|
71
|
+
3. call opt_parse()
|
72
72
|
|
73
|
-
|
73
|
+
selected_command_name = opt_parse()
|
74
74
|
|
75
|
-
== Custom Completion
|
76
|
-
|
77
|
-
|
75
|
+
== Custom Completion
|
76
|
+
The command list_actions can be called from your application, so that the user
|
77
|
+
can have custom completion.
|
78
78
|
|
79
79
|
opts.on("--list-actions", "list actions for autocompletion ") do |v|
|
80
|
-
|
81
|
-
|
80
|
+
Subcommands::list_actions
|
81
|
+
exit 0
|
82
82
|
end
|
83
83
|
|
84
|
-
|
85
|
-
|
84
|
+
Now we can place something like this in a configuration file. Here's what i placed
|
85
|
+
in .zshrc for bugzyrb.
|
86
86
|
|
87
87
|
_bugzyrb() {
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
reply=(`bugzyrb --list-actions`)
|
89
|
+
}
|
90
|
+
compctl -K _bugzyrb bugzyrb
|
91
91
|
|
92
|
-
|
92
|
+
Now, on the command line when I type "bugzyrb <TAB>" the actions are prompted in a menu.
|
93
93
|
|
94
94
|
== Sample Output
|
95
95
|
|
96
|
-
|
96
|
+
$ ruby subcommand.rb help
|
97
97
|
|
98
|
-
|
99
|
-
|
98
|
+
Usage: subcommand.rb [options] [subcommand [options]]
|
99
|
+
Stupid program that does something
|
100
100
|
|
101
|
-
|
102
|
-
|
101
|
+
Global options are:
|
102
|
+
-v, --[no-]verbose Run verbosely
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
|
104
|
+
Commands are:
|
105
|
+
foo : desc for foo
|
106
|
+
baz : desc for baz
|
107
107
|
|
108
|
-
|
109
|
-
|
108
|
+
Aliases:
|
109
|
+
goo - foo
|
110
110
|
|
111
|
-
|
111
|
+
See 'subcommand.rb help COMMAND' for more information on a specific command.
|
112
112
|
|
113
113
|
|
114
|
-
|
114
|
+
$ ruby subcommand.rb help foo
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
|
116
|
+
Usage: foo [options]
|
117
|
+
desc for foo
|
118
|
+
-f, --[no-]force force action
|
119
119
|
|
120
120
|
== Install
|
121
121
|
|
122
|
-
|
122
|
+
sudo gem install subcommand
|
123
123
|
|
124
124
|
Or, copy into your lib directory and require (see source for sample usage)
|
125
125
|
|
126
|
-
== Testing
|
126
|
+
== Testing
|
127
127
|
|
128
|
-
This comes with a bunch of test cases, that I think cover all cases including printing help
|
129
|
-
for aliases.
|
128
|
+
This comes with a bunch of test cases, that I think cover all cases including printing help
|
129
|
+
for aliases.
|
130
130
|
|
131
131
|
make test
|
132
132
|
|
133
|
-
You should have no errors. The test cases are in the **tests** folder.
|
133
|
+
You should have no errors. The test cases are in the **tests** folder.
|
134
134
|
|
135
|
-
== RDOC
|
135
|
+
== RDOC
|
136
136
|
|
137
|
-
http://subcommand.rubyforge.org/doc/
|
137
|
+
http://subcommand.rubyforge.org/doc/
|
138
138
|
|
139
|
-
== Copyright
|
139
|
+
== Copyright
|
140
140
|
|
141
|
-
Copyright (c) 2010-2019 Rahul Kumar. See LICENSE for details.
|
141
|
+
Copyright (c) 2010-2019 Rahul Kumar. See LICENSE for details.
|
142
142
|
|
143
|
-
== Others
|
143
|
+
== Others
|
144
144
|
|
145
|
-
This simple gem is still working fine. No need for a new release.
|
146
|
-
Working with ruby 1.9 through 2.6.
|
145
|
+
This simple gem is still working fine. No need for a new release.
|
146
|
+
Working with ruby 1.9 through 2.6. And now ruby 3.1.2p20.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.8
|
data/subcommand.gemspec
CHANGED
@@ -1,14 +1,11 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
1
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version =
|
2
|
+
s.name = "subcommand"
|
3
|
+
s.version = "1.0.8"
|
6
4
|
|
7
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = [
|
9
|
-
s.
|
10
|
-
s.
|
11
|
-
s.email = %q{oneness.univ@gmail.com}
|
6
|
+
s.authors = ["Rahul Kumar"]
|
7
|
+
s.description = "Subcommand and alias facility (wrapping OptionParser) for command line programs with elegant help printing"
|
8
|
+
s.email = "oneness.univ@gmail.com"
|
12
9
|
s.extra_rdoc_files = [
|
13
10
|
"LICENSE",
|
14
11
|
"README.rdoc",
|
@@ -41,20 +38,20 @@ Gem::Specification.new do |s|
|
|
41
38
|
"tests/test.rb",
|
42
39
|
"tests/test1.rb"
|
43
40
|
]
|
44
|
-
s.homepage =
|
45
|
-
s.require_paths = [
|
46
|
-
s.rubyforge_project =
|
47
|
-
s.summary =
|
41
|
+
s.homepage = "http://github.com/rkumar/subcommand"
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubyforge_project = "subcommand"
|
44
|
+
s.summary = "A tiny wrapper over OptionParser giving simple, elegant subcommand facility"
|
48
45
|
|
49
|
-
if s.respond_to? :specification_version
|
50
|
-
s.specification_version = 3
|
46
|
+
if s.respond_to? :specification_version
|
51
47
|
|
52
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new(
|
53
|
-
s.add_development_dependency(
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.2.0")
|
49
|
+
s.add_development_dependency("yard", [">= 0"])
|
54
50
|
else
|
55
|
-
s.add_dependency(
|
51
|
+
s.add_dependency("yard", [">= 0"])
|
56
52
|
end
|
57
53
|
else
|
58
|
-
s.add_dependency(
|
54
|
+
s.add_dependency("yard", [">= 0"])
|
59
55
|
end
|
56
|
+
s.metadata["rubygems_mfa_required"] = "true"
|
60
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subcommand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rahul Kumar
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|
@@ -62,8 +62,9 @@ files:
|
|
62
62
|
- tests/test1.rb
|
63
63
|
homepage: http://github.com/rkumar/subcommand
|
64
64
|
licenses: []
|
65
|
-
metadata:
|
66
|
-
|
65
|
+
metadata:
|
66
|
+
rubygems_mfa_required: 'true'
|
67
|
+
post_install_message:
|
67
68
|
rdoc_options: []
|
68
69
|
require_paths:
|
69
70
|
- lib
|
@@ -78,8 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
79
|
- !ruby/object:Gem::Version
|
79
80
|
version: '0'
|
80
81
|
requirements: []
|
81
|
-
rubygems_version: 3.
|
82
|
-
signing_key:
|
83
|
-
specification_version:
|
82
|
+
rubygems_version: 3.3.11
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
84
85
|
summary: A tiny wrapper over OptionParser giving simple, elegant subcommand facility
|
85
86
|
test_files: []
|