clamp 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/examples/admin +1 -1
- data/examples/flipflop +1 -1
- data/examples/fubar +1 -1
- data/examples/subcommand_missing +2 -0
- data/examples/word +27 -0
- data/lib/clamp/parameter/declaration.rb +0 -2
- data/lib/clamp/subcommand/execution.rb +6 -1
- data/lib/clamp/version.rb +1 -1
- data/spec/clamp/command_group_spec.rb +8 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b66f072d297e47ff393380b7507588265bfb147f
|
4
|
+
data.tar.gz: d4ab396390d9d8b850bcc74c39663bdd1f808a00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b37599b12abd509ef7d8f59e6267d624622d15ce34c7abf19c5669fc4d181dd418123aa567cfde22aae521db1363ba0022ca2a3ff4c17ef58823745f38e1d38e
|
7
|
+
data.tar.gz: 3f9e439caa164fec96a18ccabe438b6cc2f0edda1f7c09c76181c4f56b47c02b084995d36185ab2f702ec9bc0c81a5d1975e3ece7fb6b6f00b9d71273325c64e
|
data/CHANGES.md
CHANGED
data/examples/admin
CHANGED
data/examples/flipflop
CHANGED
data/examples/fubar
CHANGED
data/examples/subcommand_missing
CHANGED
data/examples/word
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
# Demonstrate "restful" style; parameters precede subcommands
|
4
|
+
|
5
|
+
require "clamp"
|
6
|
+
|
7
|
+
Clamp do
|
8
|
+
|
9
|
+
banner %(
|
10
|
+
Word ops.
|
11
|
+
)
|
12
|
+
|
13
|
+
parameter "WORD", "the word in question"
|
14
|
+
|
15
|
+
subcommand "say", "Say it" do
|
16
|
+
def execute
|
17
|
+
puts word
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
subcommand "shout", "Say it loud" do
|
22
|
+
def execute
|
23
|
+
puts word.upcase
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -15,7 +15,7 @@ module Clamp
|
|
15
15
|
|
16
16
|
def instantiate_subcommand(name)
|
17
17
|
subcommand_class = find_subcommand_class(name)
|
18
|
-
subcommand = subcommand_class.new(
|
18
|
+
subcommand = subcommand_class.new(invocation_path_for(name), context)
|
19
19
|
self.class.inheritable_attributes.each do |attribute|
|
20
20
|
next unless attribute.of(self).defined?
|
21
21
|
attribute.of(subcommand).set(attribute.of(self).get)
|
@@ -23,6 +23,11 @@ module Clamp
|
|
23
23
|
subcommand
|
24
24
|
end
|
25
25
|
|
26
|
+
def invocation_path_for(name)
|
27
|
+
param_names = self.class.inheritable_parameters.map(&:name)
|
28
|
+
[invocation_path, *param_names, name].join(" ")
|
29
|
+
end
|
30
|
+
|
26
31
|
def find_subcommand_class(name)
|
27
32
|
subcommand_def = self.class.find_subcommand(name)
|
28
33
|
return subcommand_def.subcommand_class if subcommand_def
|
data/lib/clamp/version.rb
CHANGED
@@ -258,6 +258,14 @@ describe Clamp::Command do
|
|
258
258
|
expect(stdout.strip).to eql "MONEY"
|
259
259
|
end
|
260
260
|
|
261
|
+
it "shows parameter in usage help" do
|
262
|
+
begin
|
263
|
+
command.run(["stuff", "say", "--help"])
|
264
|
+
rescue Clamp::HelpWanted => e
|
265
|
+
expect(e.command.invocation_path).to eql("with THING say")
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
261
269
|
end
|
262
270
|
|
263
271
|
describe "each subcommand" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clamp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Clamp provides an object-model for command-line utilities.
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- examples/scoop
|
39
39
|
- examples/speak
|
40
40
|
- examples/subcommand_missing
|
41
|
+
- examples/word
|
41
42
|
- lib/clamp.rb
|
42
43
|
- lib/clamp/attribute/declaration.rb
|
43
44
|
- lib/clamp/attribute/definition.rb
|
@@ -85,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
86
|
version: '0'
|
86
87
|
requirements: []
|
87
88
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.
|
89
|
+
rubygems_version: 2.6.10
|
89
90
|
signing_key:
|
90
91
|
specification_version: 4
|
91
92
|
summary: a minimal framework for command-line utilities
|