bales 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -5
- data/lib/bales/application.rb +7 -1
- data/lib/bales/command.rb +8 -0
- data/lib/bales/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17c462972479f90f386f6ea8b6e5f710ae18262e
|
4
|
+
data.tar.gz: 72374a11afb564934358320e62eb0e69176b3847
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44a588c1e833245146d6366abd2e12736bbb019d0ee771833eac545c74a5cca79f75f5ed9e5fbf55a3ccf4827ecd45db71357ed11ba59a35e638dd6db7f33c87
|
7
|
+
data.tar.gz: e54a24cbc39f4a8248a339bf25c5b5cc11e330190887b6adf7d87fc8bc5d47a6b59b78625d91d004e2b6904018325fd3724ea0f116c5393e6da6bb0049804e4b
|
data/README.md
CHANGED
@@ -26,9 +26,8 @@ module SimpleApp
|
|
26
26
|
short_form: '-2',
|
27
27
|
type: String
|
28
28
|
|
29
|
-
action do |
|
30
|
-
|
31
|
-
puts "Hello, #{opts[:recipient]}!"
|
29
|
+
action do |recipient: "world"|
|
30
|
+
puts "Hello, #{recipient}!"
|
32
31
|
end
|
33
32
|
|
34
33
|
# Subcommand
|
@@ -39,8 +38,8 @@ module SimpleApp
|
|
39
38
|
short_form: '-w',
|
40
39
|
long_form: '--with'
|
41
40
|
|
42
|
-
action do
|
43
|
-
suffix =
|
41
|
+
action do |*victims, weapon: nil|
|
42
|
+
suffix = weapon ? " with a #{weapon}" : ""
|
44
43
|
|
45
44
|
if victims.none?
|
46
45
|
puts "You have been smacked#{suffix}."
|
@@ -53,6 +52,13 @@ module SimpleApp
|
|
53
52
|
# Specify subcommand's parent class
|
54
53
|
command "help", parent: Bales::Command::Help
|
55
54
|
|
55
|
+
# Subsubcommands!
|
56
|
+
command "smack with" do
|
57
|
+
action do |weapon, *victims|
|
58
|
+
SimpleApp::Command::Smack.run(*victims, weapon: weapon)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
56
62
|
# This is what makes the app actually run!
|
57
63
|
parse_and_run
|
58
64
|
end
|
@@ -79,6 +85,8 @@ Bruce has been smacked.
|
|
79
85
|
Bruce has been smacked.
|
80
86
|
$ simple-app smack Bruce --with fish
|
81
87
|
Bruce has been smacked with a fish.
|
88
|
+
$ simple-app smack with fish Bruce
|
89
|
+
Bruce has been smacked with a fish.
|
82
90
|
```
|
83
91
|
|
84
92
|
## So how does it work?
|
data/lib/bales/application.rb
CHANGED
@@ -45,7 +45,7 @@ module Bales
|
|
45
45
|
end
|
46
46
|
|
47
47
|
##
|
48
|
-
# Set or retrieve the application's banner
|
48
|
+
# Set or retrieve the application's banner
|
49
49
|
def self.banner(text=nil)
|
50
50
|
root_command.banner(text) unless text.nil?
|
51
51
|
root_command.banner
|
@@ -58,6 +58,12 @@ module Bales
|
|
58
58
|
root_command.description
|
59
59
|
end
|
60
60
|
|
61
|
+
##
|
62
|
+
# Alias for +description+
|
63
|
+
def self.desc(text=nil)
|
64
|
+
self.description(text)
|
65
|
+
end
|
66
|
+
|
61
67
|
##
|
62
68
|
# Set or retrieve the application's summary
|
63
69
|
def self.summary(text=nil)
|
data/lib/bales/command.rb
CHANGED
@@ -60,6 +60,12 @@ module Bales
|
|
60
60
|
const_set "DESCRIPTION", "(no description)"
|
61
61
|
end
|
62
62
|
|
63
|
+
##
|
64
|
+
# Alias for +description+
|
65
|
+
def self.desc(text=nil)
|
66
|
+
self.description(text)
|
67
|
+
end
|
68
|
+
|
63
69
|
##
|
64
70
|
# Get the command's summary, or set it if a string is passed to
|
65
71
|
# it.
|
@@ -203,6 +209,8 @@ module Bales
|
|
203
209
|
opts[:default] = false if opts[:type] <= TrueClass
|
204
210
|
opts[:default] = true if opts[:type] <= FalseClass
|
205
211
|
|
212
|
+
opts[:description] = opts[:desc] if opts.key?(:desc)
|
213
|
+
|
206
214
|
result = options
|
207
215
|
result[name] = opts
|
208
216
|
options = result
|
data/lib/bales/version.rb
CHANGED