foobara-sh-cli-connector 0.0.10 → 0.0.13
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 +12 -0
- data/src/sh_cli_connector/inputs_parser.rb +2 -0
- data/src/sh_cli_connector/request.rb +3 -2
- data/src/sh_cli_connector/serializers/cli_tabular_serialzier.rb +2 -2
- data/src/sh_cli_connector.rb +61 -43
- metadata +8 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baee3b1690dc7108efe1763f106088b5c60ec44bee67f9e5e973af806dc23dcb
|
4
|
+
data.tar.gz: ff4692056eed0949ef1c4f1b0ece541e3c5805ed9afd1fb282feb35727c48780
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c45bc3cb9f0d47d3ec1dce2cc6fb7ce34712905f9f2c8895d03c56ba5e3bc1a285bc5f325740d17c5d7f6403e17892836b71829f0d065e1c4e0d124823e5c97d
|
7
|
+
data.tar.gz: 7de22a9ff9f3f780b08eb8cb4587204232d7d5e8bd00ccedfead314d737401acd31a51c26a13bc68ad518ec336003e1332aabf2ff40040b336ed70b897fb555a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## [0.0.13] - 2025-03-28
|
2
|
+
|
3
|
+
- Handle recent #request_to_response refactor
|
4
|
+
|
5
|
+
## [0.0.12] - 2025-03-06
|
6
|
+
|
7
|
+
- Allow passing a command or connect args to single_command_mode:
|
8
|
+
|
9
|
+
## [0.0.11] - 2025-01-07
|
10
|
+
|
11
|
+
- Bump Ruby to 3.4.1
|
12
|
+
|
1
13
|
## [0.0.10] - 2024-12-09
|
2
14
|
|
3
15
|
- Do not explode when serializing an empty table
|
@@ -11,6 +11,8 @@ module Foobara
|
|
11
11
|
|
12
12
|
def validate!
|
13
13
|
unless remainder.empty?
|
14
|
+
# TODO: let's invert the order for single command mode: parse inputs first, then global from remainder,
|
15
|
+
# and then raise if there's anything left
|
14
16
|
raise ParseError, "Unexpected argument: #{remainder.first}"
|
15
17
|
end
|
16
18
|
end
|
@@ -120,6 +120,7 @@ module Foobara
|
|
120
120
|
# TODO: needs to be the only registered command
|
121
121
|
self.argument = command
|
122
122
|
self.inputs_argv = argv
|
123
|
+
self.command_class = command.command_class
|
123
124
|
end
|
124
125
|
end
|
125
126
|
|
@@ -144,9 +145,9 @@ module Foobara
|
|
144
145
|
end
|
145
146
|
|
146
147
|
def validate_parse_result!
|
147
|
-
if
|
148
|
+
if %w[help list].include?(action)
|
148
149
|
# This gives some leniency around where the global options are when there's no command
|
149
|
-
result
|
150
|
+
result = globalish_parser.parse(inputs_argv)
|
150
151
|
|
151
152
|
if result.remainder.any?
|
152
153
|
# :nocov:
|
@@ -172,8 +172,8 @@ module Foobara
|
|
172
172
|
|
173
173
|
parts_size = parts.size
|
174
174
|
|
175
|
-
parts.each.with_index do |rows_worth,
|
176
|
-
rows_worth << "-" unless
|
175
|
+
parts.each.with_index do |rows_worth, inner_index|
|
176
|
+
rows_worth << "-" unless inner_index == parts_size - 1
|
177
177
|
cell << rows_worth
|
178
178
|
end
|
179
179
|
else
|
data/src/sh_cli_connector.rb
CHANGED
@@ -7,10 +7,22 @@ module Foobara
|
|
7
7
|
|
8
8
|
def initialize(*, program_name: File.basename($PROGRAM_NAME), single_command_mode: false, **, &)
|
9
9
|
self.program_name = program_name
|
10
|
-
|
10
|
+
|
11
|
+
connect_args = if single_command_mode
|
12
|
+
self.single_command_mode = true
|
13
|
+
|
14
|
+
if single_command_mode.is_a?(::Array)
|
15
|
+
single_command_mode
|
16
|
+
elsif single_command_mode.is_a?(::Class) && single_command_mode < Foobara::Command
|
17
|
+
[single_command_mode]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
11
21
|
super(*, **, &)
|
12
22
|
|
13
|
-
|
23
|
+
if connect_args
|
24
|
+
connect(*connect_args)
|
25
|
+
end
|
14
26
|
end
|
15
27
|
|
16
28
|
def connect(...)
|
@@ -53,48 +65,54 @@ module Foobara
|
|
53
65
|
nil
|
54
66
|
end
|
55
67
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
68
|
+
def set_response_status(response)
|
69
|
+
request = response.request
|
70
|
+
|
71
|
+
response.status = if request.error
|
72
|
+
6
|
73
|
+
elsif request.success?
|
74
|
+
0
|
75
|
+
else
|
76
|
+
errors = request.error_collection.error_array
|
77
|
+
error = errors.first
|
78
|
+
|
79
|
+
case error
|
80
|
+
when CommandConnector::NotFoundError, Foobara::Entity::NotFoundError
|
81
|
+
# TODO: we should not be coupled to Entities here...
|
82
|
+
# :nocov:
|
83
|
+
2
|
84
|
+
# :nocov:
|
85
|
+
when CommandConnector::UnauthenticatedError
|
86
|
+
# :nocov:
|
87
|
+
3
|
88
|
+
# :nocov:
|
89
|
+
when CommandConnector::NotAllowedError
|
90
|
+
# :nocov:
|
91
|
+
4
|
92
|
+
# :nocov:
|
93
|
+
when CommandConnector::UnknownError
|
94
|
+
# :nocov:
|
95
|
+
5
|
96
|
+
# :nocov:
|
97
|
+
end || 1
|
98
|
+
end
|
99
|
+
end
|
67
100
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
# :nocov:
|
84
|
-
3
|
85
|
-
# :nocov:
|
86
|
-
when CommandConnector::NotAllowedError
|
87
|
-
# :nocov:
|
88
|
-
4
|
89
|
-
# :nocov:
|
90
|
-
when CommandConnector::UnknownError
|
91
|
-
# :nocov:
|
92
|
-
5
|
93
|
-
# :nocov:
|
94
|
-
end || 1
|
95
|
-
end
|
96
|
-
|
97
|
-
Response.new(status:, body:, request:)
|
101
|
+
def set_response_body(response)
|
102
|
+
request = response.request
|
103
|
+
|
104
|
+
response.body = if request.error
|
105
|
+
case request.error
|
106
|
+
when ParseError, CommandConnector::NotFoundError
|
107
|
+
request.error.message
|
108
|
+
else
|
109
|
+
# :nocov:
|
110
|
+
raise "Not sure how to handle error: #{request.error}"
|
111
|
+
# :nocov:
|
112
|
+
end
|
113
|
+
else
|
114
|
+
request.response_body
|
115
|
+
end
|
98
116
|
end
|
99
117
|
end
|
100
118
|
end
|
metadata
CHANGED
@@ -1,30 +1,28 @@
|
|
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-28 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: foobara
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
|
-
- - "
|
16
|
+
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
18
|
+
version: 0.0.88
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
|
-
- - "
|
23
|
+
- - "~>"
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
description:
|
25
|
+
version: 0.0.88
|
28
26
|
email:
|
29
27
|
- azimux@gmail.com
|
30
28
|
executables: []
|
@@ -64,7 +62,6 @@ metadata:
|
|
64
62
|
source_code_uri: https://github.com/foobara/sh-cli-connector
|
65
63
|
changelog_uri: https://github.com/foobara/sh-cli-connector/blob/main/CHANGELOG.md
|
66
64
|
rubygems_mfa_required: 'true'
|
67
|
-
post_install_message:
|
68
65
|
rdoc_options: []
|
69
66
|
require_paths:
|
70
67
|
- lib
|
@@ -72,15 +69,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
69
|
requirements:
|
73
70
|
- - ">="
|
74
71
|
- !ruby/object:Gem::Version
|
75
|
-
version: 3.
|
72
|
+
version: 3.4.0
|
76
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
74
|
requirements:
|
78
75
|
- - ">="
|
79
76
|
- !ruby/object:Gem::Version
|
80
77
|
version: '0'
|
81
78
|
requirements: []
|
82
|
-
rubygems_version: 3.
|
83
|
-
signing_key:
|
79
|
+
rubygems_version: 3.6.6
|
84
80
|
specification_version: 4
|
85
81
|
summary: Command-line connector for Foobara
|
86
82
|
test_files: []
|