command_lion 2.0.0 → 2.0.1

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7831b7dfa26eb6ba19e07b982ec5fa0b32f1340935148718820fa2ba07e719be
4
- data.tar.gz: 965035c76c95b12680ca63b9ff36c58a7e46d23869246ef02d97c2770d7f865b
3
+ metadata.gz: 439d3135bc9686dd36e5c0ce34d3a0f6d2f962555589056f3d38b33ec3c14ebb
4
+ data.tar.gz: bc5648e5f62fc340e900050eda6a48d4a213d47eafc52a047ac636561607a690
5
5
  SHA512:
6
- metadata.gz: 1bdd309f3238c084d791969dedc0248792835ed84ec247bdb7c166b26ec1a07d59245f864edc1404f1300e65c059affd8034c6efb12e95f2e88cbcfb2c517e13
7
- data.tar.gz: 4942b2bea29cf5663ea59330ada573370cea73dbcbc2d113087726c0df82a1a68f47982e9402c7e4d0c02a6161f569d3c52b139cef4ccef6428b592d041f48c8
6
+ metadata.gz: 53c2ee22c0d7c5e287d7b81d52cd89f632b6f7631c4a05f4b06c3ac6a015384a7724d561837650bee5565c9455a39f1a87eb8824fcedaa1dea256ccc469d1b44
7
+ data.tar.gz: 1a23d1f22468777a6808017816e1d573607e0ee68616446e8ece7a01b8df797d776cff26b1741f8691939e1d30b8915868784550df404e34d05d2f727dd3e3ab
@@ -0,0 +1,25 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "command_lion"
3
+ require "base64"
4
+
5
+ CommandLion::App.run do
6
+ name "base64"
7
+ version "1.0.0"
8
+ description "base64 encoder and decoder"
9
+
10
+ command :encode do
11
+ description "Base64 encode a given string."
12
+ type :string
13
+ action do
14
+ puts Base64.encode64(argument).strip
15
+ end
16
+ end
17
+
18
+ command :decode do
19
+ description "Base64 decode a given string."
20
+ type :string
21
+ action do
22
+ puts Base64.decode64(argument)
23
+ end
24
+ end
25
+ end
@@ -13,5 +13,8 @@ CommandLion::App.run do
13
13
  end
14
14
  end
15
15
 
16
+ command :json do
17
+ flag "--json"
18
+ end
16
19
  end
17
20
 
@@ -3,20 +3,34 @@ module CommandLion
3
3
  class App < Base
4
4
 
5
5
  def self.default_help(app)
6
- flagz = app.commands.map do |_, cmd|
6
+ flagz = []
7
+ app.commands.each do |_, cmd|
8
+ if cmd.options?
9
+ cmd.options.each do |_, opt|
10
+ if opt.flags?
11
+ if opt.flags.long?
12
+ flagz << opt.flags.short + opt.flags.long
13
+ else
14
+ flagz << opt.flags.short
15
+ end
16
+ elsif opt.index?
17
+ flagz << opt.index.to_s if opt.index?
18
+ end
19
+ end
20
+ end
7
21
  if cmd.flags?
8
22
  if cmd.flags.long?
9
- cmd.flags.short + cmd.flags.long
23
+ flagz << cmd.flags.short + cmd.flags.long
10
24
  else
11
- cmd.flags.short
25
+ flagz << cmd.flags.short
12
26
  end
13
27
  elsif cmd.index?
14
- cmd.index.to_s if cmd.index?
28
+ flagz << cmd.index.to_s if cmd.index?
15
29
  else
16
30
  raise "No flags or index was given!"
17
31
  end
18
32
  end
19
- max_flag = flagz.map(&:length).max + 2
33
+ max_flag = flagz.map(&:length).max + 4
20
34
  max_desc = app.commands.values.map(&:description).select{|d| d unless d.nil? }.map(&:length).max
21
35
  puts app.name
22
36
  if app.version?
@@ -170,7 +184,6 @@ module CommandLion
170
184
  @flags << option.index.to_s
171
185
  end
172
186
  @commands[option.index] = option
173
- #@commands << option
174
187
  end
175
188
  end
176
189
  @commands[cmd.index] = cmd
@@ -1,3 +1,3 @@
1
1
  module CommandLion
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: command_lion
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kent 'picat' Gruber
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-19 00:00:00.000000000 Z
11
+ date: 2018-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -71,6 +71,7 @@ files:
71
71
  - bin/console
72
72
  - bin/setup
73
73
  - command_lion.gemspec
74
+ - examples/base64.rb
74
75
  - examples/ctrl_c.rb
75
76
  - examples/debug.rb
76
77
  - examples/error.rb