cmd_executable 1.2.0 → 1.2.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 +4 -4
- data/lib/cmd_executable.rb +1 -1
- data/lib/cmd_executable/parser.rb +3 -1
- data/lib/cmd_executable/runner.rb +7 -0
- data/lib/cmd_executable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abe5b341ee72889b2f6fef8fb49674f4a264139c99930a568e454fa39f602595
|
4
|
+
data.tar.gz: 057b080db6987e538dde260cc789eb4033d4821f437da68baebd8bbdf9b52413
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 179e29ce611cb66c883b3619b46102a82356c8b76eee5060efdbd78b1363bd67abb5dc3adae80698fa7d9493aa868de0376312c92ada9f327bfc4af7375d9c7f
|
7
|
+
data.tar.gz: 7518809cc0626aa005aa844d881f4191e6e44cadb674f884873f2775860d498f0e4d4fd8e5a2fb6534ea2ed62448f36be6b79c7d943e6af1d4c1a026d0ddda7b
|
data/lib/cmd_executable.rb
CHANGED
@@ -48,7 +48,7 @@ module CmdExecutable
|
|
48
48
|
|
49
49
|
def self.executable?(command)
|
50
50
|
parsed = CmdExecutable::Parser.new(command)
|
51
|
-
raise
|
51
|
+
raise CmdExecutable::ParserError, parsed.raw unless parsed.validate?
|
52
52
|
|
53
53
|
`type "#{parsed.command}" > /dev/null 2>&1`.yield_self do
|
54
54
|
$CHILD_STATUS.success?
|
@@ -29,6 +29,8 @@ module CmdExecutable
|
|
29
29
|
|
30
30
|
# Parser for CmdExecutable
|
31
31
|
class Parser
|
32
|
+
attr_reader :raw
|
33
|
+
|
32
34
|
def initialize(raw)
|
33
35
|
@raw = raw
|
34
36
|
@raw.freeze
|
@@ -59,7 +61,7 @@ module CmdExecutable
|
|
59
61
|
end
|
60
62
|
|
61
63
|
def parse
|
62
|
-
raise CmdExecutable::ParserError unless validate?
|
64
|
+
raise CmdExecutable::ParserError, @raw unless validate?
|
63
65
|
|
64
66
|
path = escape_char(@raw.to_s.chomp)
|
65
67
|
@dirname = parse_dirname(path)
|
@@ -34,6 +34,10 @@ module CmdExecutable
|
|
34
34
|
class Runner < Thor
|
35
35
|
include CmdExecutable
|
36
36
|
|
37
|
+
def self.exit_on_failure?
|
38
|
+
true
|
39
|
+
end
|
40
|
+
|
37
41
|
map '-c' => :check
|
38
42
|
|
39
43
|
desc '-c [/path/to/command]', "It's return true if given command usable on Linux."
|
@@ -45,6 +49,9 @@ module CmdExecutable
|
|
45
49
|
puts 'NOT FOUND'
|
46
50
|
exit 1
|
47
51
|
end
|
52
|
+
rescue CmdExecutable::ParserError => e
|
53
|
+
warn "Invalid command: `#{e.message}'"
|
54
|
+
exit 16
|
48
55
|
end
|
49
56
|
|
50
57
|
map %w[-v --version] => :version
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmd_executable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toshiki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|