foobara-sh-cli-connector 0.0.16 → 0.0.18
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/CHANGELOG.md +9 -0
- data/src/sh_cli_connector/action_parser.rb +9 -8
- data/src/sh_cli_connector/commands/help.rb +7 -7
- data/src/sh_cli_connector/globalish_parser.rb +2 -2
- data/src/sh_cli_connector/inputs_parser.rb +1 -1
- data/src/sh_cli_connector/request.rb +6 -4
- data/src/sh_cli_connector/serializers/cli_result_serializer.rb +9 -4
- data/src/sh_cli_connector.rb +15 -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: 321c16a5eb440c4866618f3692059e2214cc4542c423b1f61cb10919b41d20f2
|
4
|
+
data.tar.gz: 186278107ea0d9d418750d0c22af5ed6498d57fda383f36e5f33796bbe4992d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c605f79f67c4f8888b2d744eabef55413a07960cd463cf801c8c0649a3b4a441f9f624cf76f12f7130993f3e73a16dff3efbecc756cd29395dcab7169d7e8e53
|
7
|
+
data.tar.gz: ad83c744c31c7b780dd894558849fdfa6821bbc57c663e83a2b485c1079870761cb9d40b1413423f7bf09e00a35a59eabcad76dfec3ee5a42736e4e739a27adf
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## [0.0.18] - 2025-06-16
|
2
|
+
|
3
|
+
- Support Time/Date/DateTime in CliResultSerializer
|
4
|
+
|
5
|
+
## [0.0.17] - 2025-05-03
|
6
|
+
|
7
|
+
- Deal with recent CommandConnector interface changes
|
8
|
+
- Make ParseError a Foobara::Error
|
9
|
+
|
1
10
|
## [0.0.16] - 2025-04-23
|
2
11
|
|
3
12
|
- Give a way to force inputs to be fully prefixed even if they don't collide
|
@@ -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
|
@@ -92,7 +93,7 @@ module Foobara
|
|
92
93
|
end
|
93
94
|
|
94
95
|
def supported_actions
|
95
|
-
|
96
|
+
["run", "describe", "manifest", "help", "list"]
|
96
97
|
end
|
97
98
|
|
98
99
|
private
|
@@ -129,13 +129,13 @@ module Foobara
|
|
129
129
|
|
130
130
|
# TODO: maybe move this up the hierarchy?
|
131
131
|
def known_actions
|
132
|
-
|
133
|
-
run
|
134
|
-
describe
|
135
|
-
manifest
|
136
|
-
ping
|
137
|
-
query_git_commit_info
|
138
|
-
help
|
132
|
+
[
|
133
|
+
"run",
|
134
|
+
"describe",
|
135
|
+
"manifest",
|
136
|
+
"ping",
|
137
|
+
"query_git_commit_info",
|
138
|
+
"help"
|
139
139
|
]
|
140
140
|
end
|
141
141
|
|
@@ -70,7 +70,7 @@ module Foobara
|
|
70
70
|
result.parsed[:verbose] = true
|
71
71
|
end
|
72
72
|
|
73
|
-
allowed_entity_depths =
|
73
|
+
allowed_entity_depths = ["aggregate", "atomic", "record-store"]
|
74
74
|
parser.on("--entity-depth DEPTH", allowed_entity_depths, "Set the entity depth") do |depth|
|
75
75
|
depth = "record_store" if depth == "record-store"
|
76
76
|
result.parsed[:entity_depth] = depth
|
@@ -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
|
|
@@ -145,13 +147,13 @@ module Foobara
|
|
145
147
|
end
|
146
148
|
|
147
149
|
def validate_parse_result!
|
148
|
-
if
|
150
|
+
if ["help", "list"].include?(action)
|
149
151
|
# This gives some leniency around where the global options are when there's no command
|
150
152
|
result = globalish_parser.parse(inputs_argv)
|
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
|
|
@@ -77,7 +77,7 @@ module Foobara
|
|
77
77
|
if padding
|
78
78
|
io.write "#{padding}}"
|
79
79
|
end
|
80
|
-
when ::String, ::Symbol, ::Numeric, ::TrueClass, ::FalseClass, ::NilClass
|
80
|
+
when ::String, ::Symbol, ::Numeric, ::TrueClass, ::FalseClass, ::NilClass, ::Time
|
81
81
|
if after_colon
|
82
82
|
io.write " "
|
83
83
|
else
|
@@ -86,9 +86,14 @@ module Foobara
|
|
86
86
|
|
87
87
|
io.write object.inspect
|
88
88
|
else
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
if (defined?(::Date) && object.is_a?(::Date)) || (defined?(::DateTime) && object.is_a?(::DateTime))
|
90
|
+
io.write after_colon ? " " : padding
|
91
|
+
io.write object.to_s
|
92
|
+
else
|
93
|
+
# :nocov:
|
94
|
+
raise "Unsupported type: #{object.class}"
|
95
|
+
# :nocov:
|
96
|
+
end
|
92
97
|
end
|
93
98
|
end
|
94
99
|
end
|
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,7 +1,7 @@
|
|
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.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
@@ -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.9
|
80
80
|
specification_version: 4
|
81
81
|
summary: Command-line connector for Foobara
|
82
82
|
test_files: []
|