foobara-sh-cli-connector 0.0.16 → 0.0.17
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59a7b3a60573d7c637f5526e2a6d028c48906c7b5a865f2d204d64a48a25cf1f
|
4
|
+
data.tar.gz: dfc47f6db70767c09e9cab51c0c569d0ddc291f2d1abe3e29e5c7a4ecb7c9e11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6846e7d9362da9319f52d7c281feb802511199cdd0000aa6e7f40a161dc44fabc3a7676f66aee4e7795cccd6b29795efffaa2685db4e731d3f49777a9b1b91e6
|
7
|
+
data.tar.gz: 43c0b652981b6b113f92ebaaaa5f639e2915e02cb78a6e930e3e499b5524c1aa674eae9a5d7e99a603af08fff9e70c4cae1fe7c390d22db33f643acdee7cf412
|
data/CHANGELOG.md
CHANGED
@@ -14,11 +14,11 @@ module Foobara
|
|
14
14
|
def action=(action)
|
15
15
|
if @action
|
16
16
|
# :nocov:
|
17
|
-
raise ParseError
|
17
|
+
raise ParseError.new(message: "Action already set")
|
18
18
|
# :nocov:
|
19
19
|
elsif argument
|
20
20
|
# :nocov:
|
21
|
-
raise ParseError
|
21
|
+
raise ParseError.new(message: "Not expecting #{action} to appear after #{argument}")
|
22
22
|
# :nocov:
|
23
23
|
else
|
24
24
|
@action = action
|
@@ -28,7 +28,7 @@ module Foobara
|
|
28
28
|
def argument=(argument)
|
29
29
|
if @argument
|
30
30
|
# :nocov:
|
31
|
-
raise ParseError
|
31
|
+
raise ParseError.new(message: "Argument already set")
|
32
32
|
# :nocov:
|
33
33
|
end
|
34
34
|
|
@@ -37,17 +37,18 @@ module Foobara
|
|
37
37
|
|
38
38
|
def validate!
|
39
39
|
if action.nil?
|
40
|
-
raise ParseError
|
41
|
-
|
40
|
+
raise ParseError.new(
|
41
|
+
message: "Found invalid option #{remainder.first} but was expecting an action like 'run' or 'help'"
|
42
|
+
)
|
42
43
|
end
|
43
44
|
|
44
45
|
if action == "run"
|
45
46
|
unless argument
|
46
|
-
raise ParseError
|
47
|
+
raise ParseError.new(message: "Missing command to run")
|
47
48
|
end
|
48
49
|
elsif action == "describe"
|
49
50
|
unless argument
|
50
|
-
raise ParseError
|
51
|
+
raise ParseError.new(message: "Missing command or type to describe")
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
@@ -93,7 +93,7 @@ module Foobara
|
|
93
93
|
[result.parsed[:input_format], result.parsed[:output_format]].compact.uniq.each do |format|
|
94
94
|
if format
|
95
95
|
unless Serializer.serializer_from_symbol(format)
|
96
|
-
raise ParseError
|
96
|
+
raise ParseError.new(message: "Unknown format: #{format}")
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
@@ -13,7 +13,7 @@ module Foobara
|
|
13
13
|
unless remainder.empty?
|
14
14
|
# TODO: let's invert the order for single command mode: parse inputs first, then global from remainder,
|
15
15
|
# and then raise if there's anything left
|
16
|
-
raise ParseError
|
16
|
+
raise ParseError.new(message: "Unexpected argument: #{remainder.first}")
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module Foobara
|
2
2
|
module CommandConnectors
|
3
3
|
class ShCliConnector < CommandConnector
|
4
|
-
class ParseError <
|
4
|
+
class ParseError < Foobara::Error
|
5
|
+
context({})
|
6
|
+
end
|
5
7
|
|
6
8
|
class Request < CommandConnector::Request
|
7
9
|
attr_accessor :argv,
|
@@ -51,7 +53,7 @@ module Foobara
|
|
51
53
|
|
52
54
|
unless serializer_class
|
53
55
|
# :nocov:
|
54
|
-
raise ParseError
|
56
|
+
raise ParseError.new(message: "Unknown input format: #{input_format}")
|
55
57
|
# :nocov:
|
56
58
|
end
|
57
59
|
|
@@ -151,7 +153,7 @@ module Foobara
|
|
151
153
|
|
152
154
|
if result.remainder.any?
|
153
155
|
# :nocov:
|
154
|
-
raise ParseError
|
156
|
+
raise ParseError.new(message: "Found invalid options #{globalish_parser.remainder}")
|
155
157
|
# :nocov:
|
156
158
|
end
|
157
159
|
|
data/src/sh_cli_connector.rb
CHANGED
@@ -70,7 +70,21 @@ module Foobara
|
|
70
70
|
response
|
71
71
|
end
|
72
72
|
|
73
|
-
def
|
73
|
+
def request_to_command_class(request)
|
74
|
+
super
|
75
|
+
rescue CommandConnector::NoCommandFoundError, ParseError => e
|
76
|
+
request.error = e
|
77
|
+
nil
|
78
|
+
end
|
79
|
+
|
80
|
+
def request_to_command_inputs(request)
|
81
|
+
super
|
82
|
+
rescue CommandConnector::NoCommandFoundError, ParseError => e
|
83
|
+
request.error = e
|
84
|
+
nil
|
85
|
+
end
|
86
|
+
|
87
|
+
def request_to_command_instance(request)
|
74
88
|
super
|
75
89
|
rescue CommandConnector::NoCommandFoundError, ParseError => e
|
76
90
|
request.error = e
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-sh-cli-connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 2025-05-03 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: foobara
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
|
-
rubygems_version: 3.6.
|
79
|
+
rubygems_version: 3.6.2
|
80
80
|
specification_version: 4
|
81
81
|
summary: Command-line connector for Foobara
|
82
82
|
test_files: []
|