yacli 0.3.1 → 0.3.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 +4 -4
- data/README.md +3 -3
- data/lib/yacli/base.rb +1 -1
- data/lib/yacli/cli.rb +9 -14
- data/lib/yacli/version.rb +1 -1
- data/spec/base_spec.rb +24 -0
- data/yacli.gemspec +0 -1
- metadata +4 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f022deb6f751e2a13810475540f1f90dac5010f7660b3d1dbb4ab1a3be9c67e
|
4
|
+
data.tar.gz: 087e00d8b531088dd9aa4d534f8b62cdb81ff5647c425472cf68a52cd885fc68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e87b956f42499ec2fc1f72396882535fffca0d741cc86538b0cd0e28ed6063037d8f4281814bb90820042dece52b0447abec0001254f2bc7e6febadf2b36feb6
|
7
|
+
data.tar.gz: 164d396bccddb8b747a36dd0400857f4b5ec3d4025f087367de08b5127bc21278403c579dd38a7557c824b86b9afb867712eaf38c45f816fc88fc28c08345f30
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@ Yacli
|
|
3
3
|
|
4
4
|
[][gem]
|
5
5
|
[][travis]
|
6
|
-
[][codeclimate]
|
6
|
+
<!-- [][codeclimate] -->
|
7
7
|
[][coveralls]
|
8
8
|
[][codacy]
|
9
9
|
|
@@ -15,14 +15,14 @@ Yacli
|
|
15
15
|
Description
|
16
16
|
-----------
|
17
17
|
Yacli a.k.a yet another CLI, is a simple gem allowing to build custom CLI wrappers.
|
18
|
-
It uses [
|
18
|
+
It uses [Optimist][optimist] as a CLI option manager as well as additional minimal helpers for logging and output handling.
|
19
19
|
|
20
20
|
Please note: Yacli, by design, is a system tool created to allow seamless file and url
|
21
21
|
access, which should not receive application user input. It relies on [open-uri][open-uri],
|
22
22
|
which combined with application user input would provide a command injection attack
|
23
23
|
vector.
|
24
24
|
|
25
|
-
[
|
25
|
+
[optimist]: https://github.com/ManageIQ/optimist
|
26
26
|
[open-uri]: https://ruby-doc.org/stdlib-2.5.1/libdoc/open-uri/rdoc/index.html
|
27
27
|
|
28
28
|
Prerequisites
|
data/lib/yacli/base.rb
CHANGED
data/lib/yacli/cli.rb
CHANGED
@@ -1,20 +1,15 @@
|
|
1
|
-
require 'thor'
|
2
|
-
|
3
1
|
module Yacli
|
4
|
-
class Cli
|
5
|
-
def self.
|
6
|
-
method_option :'dry-run', aliases: '-d', type: :boolean, default: false
|
7
|
-
end
|
8
|
-
|
9
|
-
desc 'cli', 'run cli'
|
10
|
-
common_opts
|
11
|
-
method_option :cmd, aliases: '-c', default: 'uname'
|
12
|
-
def cli
|
2
|
+
class Cli
|
3
|
+
def self.start
|
13
4
|
require 'yacli/base'
|
14
5
|
b = Base.new
|
15
|
-
|
16
|
-
|
17
|
-
|
6
|
+
options = Base.options do
|
7
|
+
opt :cmd, "Number of limbs", :default => 'uname', :type => :string
|
8
|
+
end
|
9
|
+
b.log("running CLI with options: #{options.inspect}")
|
10
|
+
result = b.cli(options)
|
11
|
+
b.log("result: #{result.inspect}")
|
12
|
+
#b.log("I'm logging error", :error)
|
18
13
|
end
|
19
14
|
end
|
20
15
|
end
|
data/lib/yacli/version.rb
CHANGED
data/spec/base_spec.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'yacli/base'
|
3
|
+
|
4
|
+
include Helpers
|
5
|
+
|
6
|
+
describe Yacli::Run do
|
7
|
+
context 'run is successfull' do
|
8
|
+
let(:options_hash) { { :monkey=>false, :name=>nil, :num_limbs=>4, :help=>false } }
|
9
|
+
|
10
|
+
before do
|
11
|
+
#allow_any_instance_of(Yacli::Run).to receive(:pass_cli).and_return(nil)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'parse options' do
|
15
|
+
opts = Yacli::Base.options do
|
16
|
+
opt :monkey, "Use monkey mode" # flag --monkey, default false
|
17
|
+
opt :name, "Monkey name", :type => :string # string --name <s>, default nil
|
18
|
+
opt :num_limbs, "Number of limbs", :default => 4 # integer --num-limbs <i>, default to 4
|
19
|
+
end
|
20
|
+
|
21
|
+
expect(opts).to eq options_hash
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/yacli.gemspec
CHANGED
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "thor", "~> 0.20"
|
22
21
|
spec.add_dependency "optimist", "~> 3.0"
|
23
22
|
|
24
23
|
spec.add_development_dependency "rspec_junit_formatter", "~> 0.2"
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yacli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rombob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: thor
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.20'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0.20'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: optimist
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -189,6 +175,7 @@ files:
|
|
189
175
|
- lib/yacli/errors.rb
|
190
176
|
- lib/yacli/run.rb
|
191
177
|
- lib/yacli/version.rb
|
178
|
+
- spec/base_spec.rb
|
192
179
|
- spec/cli_spec.rb
|
193
180
|
- spec/run_spec.rb
|
194
181
|
- spec/spec_helper.rb
|
@@ -218,6 +205,7 @@ signing_key:
|
|
218
205
|
specification_version: 4
|
219
206
|
summary: CLI wrapper library tool
|
220
207
|
test_files:
|
208
|
+
- spec/base_spec.rb
|
221
209
|
- spec/cli_spec.rb
|
222
210
|
- spec/run_spec.rb
|
223
211
|
- spec/spec_helper.rb
|