fuelcell 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWVhMjk5MTZmYmRkMmU5YjRmZWUwZjk0ZmMwZTdmMWI5ZmRkYjQxOA==
4
+ OTg3NDk4Y2I4ZWI1YzEwOWI0NzYxODY1Y2JlZGUwYzAzNDhmMWQxZQ==
5
5
  data.tar.gz: !binary |-
6
- MTMwMWQ5ZmEzMTU2ZmJjYjM4YTVhNGNjZjk2ZGE0MDU5NjkwNDVmZA==
6
+ ZDY3MzdiNjdmM2RmYTMyNzk5MjMxZWU3MTk0ZjlhMTQ5YTdmYmJjZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWE5MjgxMzZiNDdlNWU0NjY1NmU1OTRjZDkyNzg2OThhMjVjZWFlOTgxMzI3
10
- NGMwMmY5ZTNiM2IyNjRmMzM5ZTUxNmI3MGU4MzE0Y2EwYTBjZmEwODg3OTUz
11
- Y2RkNTQ3MzYwODA0ODBjYjgwOGZhMGYwOGZlNGNlYzgxMGQ0NmM=
9
+ ODJhODQxYTcwYjg1ZmVmZDA5OGI5ZDc2M2QyNWE2ZWM3YjE2MGMwMDkxNDUx
10
+ ZDBiNjdkNmE5OTMxYzVjZjY0ZGI4OGU3MTM1YjE0NTA2NWMwOWNhODA2Y2Rh
11
+ M2VlNjljZTU2YzgxOWJlZjEzNWQwNmY4ZGUyNDUxMWY2MTdiMjM=
12
12
  data.tar.gz: !binary |-
13
- NTY5NDU2ZWRlZjc0NjFkNWM1Mzg2YTIyYzA5ZWI2YmQwNzA2Nzc5NjdkOGE4
14
- YTg4MDNiODU2NzM0YzBhYTVmYjIwMGQxMWU1Y2JiNzM2MDYyZGJiNWNiYzhj
15
- Nzk3ZDUxMzcyZTkxMTljZGMwZDlhNTZmYTg1MGYwYWRkNjFmYjg=
13
+ MWMwZDk4ZDg5YzQ1MmE2MDRiNmFjNDdjYzBhYTYxNmU4MmI3N2NhNDI3NWI3
14
+ NGFkY2RkNjkwYTQyMDczMjg0ZWMzNTZmODFmNTBlM2IxNGRmOTEzYzc4NmFi
15
+ OWM4ZmM1MDhhZDNmNDE2YzlhYzVhMGQzMDRlZmRiMmQ2NjExYjE=
data/bin/test CHANGED
@@ -7,17 +7,16 @@ require "fuelcell"
7
7
  Fuelcell.start(ARGV.dup, backtrace: true) do
8
8
  require_relative 'example'
9
9
  desc 'this is an example of how a commands work with fuelcell'
10
- opt 'all|a', banner: 'all of something', cmd_path: 'fiz'
10
+ opt 'version|v', banner: 'version of app', cmd_path: 'version', global: true
11
11
  arg 'foo', required: true
12
12
 
13
13
  run ->(opts, args, shell) {
14
14
  shell.puts "testing #{args.foo}"
15
15
  }
16
- command 'fiz' do
17
- opt 'blah'
16
+ command 'version' do
18
17
  desc 'the fiz command'
19
18
  run -> (opts, args, shell) {
20
- shell.puts "blah"
19
+ shell.puts "0.1.0"
21
20
  }
22
21
  end
23
22
  end
@@ -14,6 +14,10 @@ module Fuelcell
14
14
  options.each {|_, option| yield option }
15
15
  end
16
16
 
17
+ def callable?
18
+ !callable.nil?
19
+ end
20
+
17
21
  # Check to determine if any of the options are callable, meaning do
18
22
  # they point to another command or have a lambda to be executed
19
23
  #
@@ -12,8 +12,12 @@ module Fuelcell
12
12
  # @return [Fuelcell::Action::ArgsResults]
13
13
  def call(cmd, args)
14
14
  list = {}
15
- manager = cmd.args
16
- manager.each_with_index do |arg, index|
15
+ args_manager = cmd.args
16
+ opts_manager = cmd.opts
17
+
18
+ return create_results(args, list) if opts_manager.callable?
19
+
20
+ args_manager.each_with_index do |arg, index|
17
21
  value = args.fetch(index) {
18
22
  fail "argument at #{index} is required" if arg.required?
19
23
  arg.default? ? arg.default : SKIP
@@ -24,8 +28,15 @@ module Fuelcell
24
28
  list[arg.name] = index
25
29
  end
26
30
 
31
+ create_results(args, list)
32
+ end
33
+
34
+ private
35
+
36
+ def create_results(args, list)
27
37
  Fuelcell::Action::ArgResults.new(args, list)
28
38
  end
39
+
29
40
  end
30
41
  end
31
42
  end
@@ -1,3 +1,3 @@
1
1
  module Fuelcell
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuelcell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Scott-Buccleuch