mister_bin 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/lib/mister_bin/command.rb +20 -2
- data/lib/mister_bin/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 625bef48b831c9b258cbfbb1ea2e02e756604d8d09111d0db95aa670fcd5b002
|
4
|
+
data.tar.gz: fdb6c17c82ac45329073c95f9303359625ae76ea243db933d1b63df42833c533
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7326953c18b22157cb2fc8eadd3d32fe88ba6878e63225fc1e08a0d96417a7a004c52e29fdc2c081c38fc40882b32f350f3c4e8216364d6c4c58d56ff441715b
|
7
|
+
data.tar.gz: e749163878edec4ea78846a6e309713225818016bb337831412c01032b77114539fe2f86aae02df375471a63a1ed0036be616c21c10d361a79dc04ca59ac9163
|
data/README.md
CHANGED
@@ -200,13 +200,15 @@ version "0.1.1"
|
|
200
200
|
|
201
201
|
# Usage patterns. You can use either a compact docopt notation, or provide
|
202
202
|
# multiple usage calls.
|
203
|
-
# The first two will create the same result as the last one.
|
204
203
|
usage "app ls"
|
205
|
-
usage "app ls --all"
|
206
204
|
usage "app ls [--all]"
|
207
205
|
usage "app new NAME"
|
208
206
|
|
209
207
|
# Describe any subcommands
|
208
|
+
# Note that this has an additional important use:
|
209
|
+
# - For each command defined with the `command` directive, we will search
|
210
|
+
# for a method with the same name and a `_command` suffix.
|
211
|
+
# - If no such method is found, we will call the generic `run` method.
|
210
212
|
command "ls", "Show list of files"
|
211
213
|
command "new", "Pretend to create a new application"
|
212
214
|
|
@@ -234,8 +236,10 @@ Several examples of real world use of Mister Bin in the wild (well,
|
|
234
236
|
|
235
237
|
- [Kojo][2] - Command line utility for generating config files from templates and definition files
|
236
238
|
- [Madman][3] - The Markdown Swiss Army Knife
|
239
|
+
- [AudioAddict][4] - Command line utility for the AudioAddict radio network
|
237
240
|
|
238
241
|
|
239
242
|
[1]: http://docopt.org/
|
240
243
|
[2]: https://github.com/DannyBen/kojo
|
241
244
|
[3]: https://github.com/DannyBen/madman
|
245
|
+
[4]: https://github.com/DannyBen/audio_addict
|
data/lib/mister_bin/command.rb
CHANGED
@@ -12,7 +12,9 @@ module MisterBin
|
|
12
12
|
|
13
13
|
def execute(argv=[])
|
14
14
|
args = Docopt.docopt docopt, version: maker.version, argv: argv
|
15
|
-
|
15
|
+
instance = new
|
16
|
+
target = find_target_command instance, args
|
17
|
+
exitcode = instance.send target, args
|
16
18
|
exitcode.is_a?(Numeric) ? exitcode : 0
|
17
19
|
|
18
20
|
rescue Docopt::Exit => e
|
@@ -43,6 +45,7 @@ module MisterBin
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def command(name, text)
|
48
|
+
target_commands << name.to_sym
|
46
49
|
maker.commands << [name, text]
|
47
50
|
end
|
48
51
|
|
@@ -58,7 +61,7 @@ module MisterBin
|
|
58
61
|
maker.env_vars << [name, value]
|
59
62
|
end
|
60
63
|
|
61
|
-
|
64
|
+
protected
|
62
65
|
|
63
66
|
def maker
|
64
67
|
@maker ||= DocoptMaker.new
|
@@ -68,6 +71,21 @@ module MisterBin
|
|
68
71
|
maker.docopt
|
69
72
|
end
|
70
73
|
|
74
|
+
private
|
75
|
+
|
76
|
+
def target_commands
|
77
|
+
@target_commands ||= []
|
78
|
+
end
|
79
|
+
|
80
|
+
def find_target_command(instance, args)
|
81
|
+
target_commands.each do |target|
|
82
|
+
method_name = :"#{target}_command"
|
83
|
+
return method_name if instance.respond_to? method_name and args[target.to_s]
|
84
|
+
end
|
85
|
+
:run
|
86
|
+
end
|
87
|
+
|
71
88
|
end
|
89
|
+
|
72
90
|
end
|
73
91
|
end
|
data/lib/mister_bin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mister_bin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|