command_lion 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/base64.rb +25 -0
- data/examples/hello_world.rb +3 -0
- data/lib/command_lion/app.rb +19 -6
- data/lib/command_lion/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 439d3135bc9686dd36e5c0ce34d3a0f6d2f962555589056f3d38b33ec3c14ebb
|
4
|
+
data.tar.gz: bc5648e5f62fc340e900050eda6a48d4a213d47eafc52a047ac636561607a690
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53c2ee22c0d7c5e287d7b81d52cd89f632b6f7631c4a05f4b06c3ac6a015384a7724d561837650bee5565c9455a39f1a87eb8824fcedaa1dea256ccc469d1b44
|
7
|
+
data.tar.gz: 1a23d1f22468777a6808017816e1d573607e0ee68616446e8ece7a01b8df797d776cff26b1741f8691939e1d30b8915868784550df404e34d05d2f727dd3e3ab
|
data/examples/base64.rb
ADDED
@@ -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
|
data/examples/hello_world.rb
CHANGED
data/lib/command_lion/app.rb
CHANGED
@@ -3,20 +3,34 @@ module CommandLion
|
|
3
3
|
class App < Base
|
4
4
|
|
5
5
|
def self.default_help(app)
|
6
|
-
flagz =
|
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 +
|
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
|
data/lib/command_lion/version.rb
CHANGED
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.
|
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-
|
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
|