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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3697a0dc2411e2fed3dc7bacbd03a6d33c4ce785
4
- data.tar.gz: d5aed1d5f97a63e0505ad77de3199be86b90a7dd
3
+ metadata.gz: 17c462972479f90f386f6ea8b6e5f710ae18262e
4
+ data.tar.gz: 72374a11afb564934358320e62eb0e69176b3847
5
5
  SHA512:
6
- metadata.gz: f15a4c35d75271d03d3e22b503c8eae3e8c295e1f912e724249ec7195e375df32282a1899e059901e9f7396d911a7c6675e6497c6c8885e1b8265f5b22eb686c
7
- data.tar.gz: 9a979f78d9de61e06e719bd12951c356a8d935c38fef170f9c8ed05815a6b13e09bef24aa7b55cb7f091f1235c464d0e81762f9ea489b51713eceec83f72a531
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 |args, opts|
30
- opts[:recipient] ||= "world"
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 |victims, opts|
43
- suffix = opts[:weapon] ? " with a #{opts[:weapon]}" : ""
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?
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Bales
2
- VERSION="0.0.4"
2
+ VERSION="0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bales
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan S. Northrup