usps-imis-api 0.13.3 → 0.13.5
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/usps/imis/command_line/help.rb +40 -21
- data/lib/usps/imis/command_line/{options.yml.erb → options.yml} +16 -17
- data/lib/usps/imis/command_line/options_parser_config.rb +20 -6
- data/lib/usps/imis/command_line.rb +1 -1
- data/lib/usps/imis/logger_formatter.rb +8 -1
- data/lib/usps/imis/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: 6f533f6f1c46a836c57ed615db3e4ed3a960e1cf6e280d258cc59ee72bbe735d
|
|
4
|
+
data.tar.gz: b2877c785c60738326dc96e7aa50da21eff214e21b961a30773dc2f0f843e195
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1c032d83d0b9c87de3d0e705e330e840cf159dc252837b54b138b5ee7a791d587b21630050b05427a59d81a5c2c605331b514dbed339634a199c2fc67f61b35c
|
|
7
|
+
data.tar.gz: 6f6a335d752b0aacef359d5fb79a499e7f6224a9c884acc42730beb44ab595d4a88659545fb7ec8ae612d84c3ba16159cc568a8993a1101bbf7bca74bd399e48
|
|
@@ -8,9 +8,24 @@ module Usps
|
|
|
8
8
|
# @private
|
|
9
9
|
#
|
|
10
10
|
module Help
|
|
11
|
-
|
|
11
|
+
# Width of the terminal window
|
|
12
|
+
#
|
|
13
|
+
# :nocov:
|
|
14
|
+
TERMINAL_WIDTH = IO.console&.winsize&.at(1) || 80
|
|
15
|
+
# :nocov:
|
|
16
|
+
|
|
17
|
+
# Extra padding between columns
|
|
18
|
+
#
|
|
12
19
|
GAP = 4
|
|
13
20
|
|
|
21
|
+
# Adjust the underlying command padding to account for non-printing characters
|
|
22
|
+
#
|
|
23
|
+
# Bold and gray each add 14:
|
|
24
|
+
# '-'.bold.length == 15
|
|
25
|
+
# '-'.gray.length == 15
|
|
26
|
+
#
|
|
27
|
+
ESCAPE_PADDING = 14
|
|
28
|
+
|
|
14
29
|
def banner_header(version)
|
|
15
30
|
<<~BANNER
|
|
16
31
|
#{version.bold.blue}
|
|
@@ -19,6 +34,12 @@ module Usps
|
|
|
19
34
|
end
|
|
20
35
|
|
|
21
36
|
def banner_contents
|
|
37
|
+
wiki = word_wrap(
|
|
38
|
+
'For an explanation of how to provide API configuration, ' \
|
|
39
|
+
'more details on the options, and usage examples, please refer to the wiki:',
|
|
40
|
+
TERMINAL_WIDTH - indent(1).length
|
|
41
|
+
).join("\n#{indent(1)}")
|
|
42
|
+
|
|
22
43
|
<<~BANNER
|
|
23
44
|
#{'Usage'.underline}
|
|
24
45
|
|
|
@@ -27,8 +48,7 @@ module Usps
|
|
|
27
48
|
|
|
28
49
|
#{'Further Help'.underline}
|
|
29
50
|
|
|
30
|
-
|
|
31
|
-
and usage examples, please refer to the wiki:
|
|
51
|
+
#{wiki}
|
|
32
52
|
|
|
33
53
|
https://github.com/unitedstatespowersquadrons/imis-api-ruby/wiki/Command-Line
|
|
34
54
|
|
|
@@ -64,29 +84,21 @@ module Usps
|
|
|
64
84
|
private
|
|
65
85
|
|
|
66
86
|
def help_commands(lines)
|
|
67
|
-
# Adjust the underlying command padding to account for non-printing characters
|
|
68
|
-
#
|
|
69
|
-
# Bold and gray each add 14:
|
|
70
|
-
# '-'.bold.length == 15
|
|
71
|
-
# '-'.gray.length == 15
|
|
72
|
-
#
|
|
73
|
-
escape_padding = 14
|
|
74
|
-
|
|
75
|
-
command_lengths = subcommands.map { |name, details| name.length + details[:value].to_s.length }
|
|
76
|
-
command_width = command_lengths.max + GAP + escape_padding
|
|
77
|
-
|
|
78
87
|
lines << "#{'Commands'.underline}\n"
|
|
79
88
|
subcommands.each do |name, details|
|
|
80
89
|
combined_name = details[:value] ? "#{name.bold} #{"<#{details[:value]}>".gray}" : name.bold
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
details[:description]
|
|
85
|
-
].join
|
|
90
|
+
command = combined_name.ljust(command_width + (details[:value] ? ESCAPE_PADDING : 0))
|
|
91
|
+
left_width = indent(1).length + command_width
|
|
92
|
+
lines << "#{indent(1)}#{command}#{wrap_description(details[:description], left_width)}"
|
|
86
93
|
end
|
|
87
94
|
lines << "\n"
|
|
88
95
|
end
|
|
89
96
|
|
|
97
|
+
def command_width
|
|
98
|
+
command_lengths = subcommands.map { |name, details| name.length + details[:value].to_s.length }
|
|
99
|
+
command_lengths.max + GAP + ESCAPE_PADDING
|
|
100
|
+
end
|
|
101
|
+
|
|
90
102
|
def help_options(lines)
|
|
91
103
|
lines << "#{'Options'.underline}\n"
|
|
92
104
|
option_groups.each do |group_name, option_keys|
|
|
@@ -98,9 +110,16 @@ module Usps
|
|
|
98
110
|
|
|
99
111
|
def help_legacy_flags(lines)
|
|
100
112
|
lines << "#{indent(1)}#{'Legacy Flags'.underline}\n"
|
|
101
|
-
|
|
113
|
+
explanation = word_wrap(
|
|
114
|
+
'The following options are still supported, but have been replaced by subcommands:',
|
|
115
|
+
TERMINAL_WIDTH - indent(2).length
|
|
116
|
+
).join("\n#{indent(2)}")
|
|
117
|
+
lines << "#{indent(2)}#{explanation}\n"
|
|
118
|
+
|
|
102
119
|
legacy_flags.each do |flags, replacement|
|
|
103
|
-
|
|
120
|
+
left_width = indent(2).length + option_column_width
|
|
121
|
+
description = wrap_description("use: #{replacement}", left_width)
|
|
122
|
+
lines << "#{indent(2)}#{flags.ljust(option_column_width)}#{description}"
|
|
104
123
|
end
|
|
105
124
|
lines << "\n"
|
|
106
125
|
end
|
|
@@ -27,10 +27,10 @@ Subcommands:
|
|
|
27
27
|
- Interact with mapped fields
|
|
28
28
|
- short: M
|
|
29
29
|
map:
|
|
30
|
-
description:
|
|
30
|
+
description: Shorthand for `%{green:mapper -f}` to access a single mapped field
|
|
31
31
|
value: field
|
|
32
32
|
option:
|
|
33
|
-
-
|
|
33
|
+
- Shorthand for %{green:-Mf} to access a single mapped field
|
|
34
34
|
- type: string
|
|
35
35
|
short: m
|
|
36
36
|
business-objects:
|
|
@@ -65,13 +65,13 @@ Options:
|
|
|
65
65
|
|
|
66
66
|
Business Object or Panel:
|
|
67
67
|
create:
|
|
68
|
-
-
|
|
68
|
+
- Send a %{cyan:POST} request
|
|
69
69
|
- short: C
|
|
70
70
|
delete:
|
|
71
|
-
-
|
|
71
|
+
- Send a %{cyan:DELETE} request
|
|
72
72
|
- short: D
|
|
73
73
|
all:
|
|
74
|
-
-
|
|
74
|
+
- Send a %{cyan:GET} request for all records for a member
|
|
75
75
|
- short: A
|
|
76
76
|
|
|
77
77
|
Panel:
|
|
@@ -106,7 +106,7 @@ Options:
|
|
|
106
106
|
- type: strings
|
|
107
107
|
short: F
|
|
108
108
|
data:
|
|
109
|
-
-
|
|
109
|
+
- JSON string input -- %{red:STDIN} takes priority
|
|
110
110
|
- type: string
|
|
111
111
|
short: d
|
|
112
112
|
|
|
@@ -126,21 +126,20 @@ Options:
|
|
|
126
126
|
|
|
127
127
|
Configuration:
|
|
128
128
|
config:
|
|
129
|
-
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
\nIf no option is provided, the first matching preset option will be automatically used."
|
|
129
|
+
- >-
|
|
130
|
+
Path to the JSON/YAML config file to use, or one of the following preset options:
|
|
131
|
+
|
|
132
|
+
`%{yellow:local_dot}`, `%{yellow:local}`, `%{yellow:local_dot_config}`,
|
|
133
|
+
`%{yellow:local_config}`, `%{yellow:user}`, `%{yellow:system}`
|
|
134
|
+
|
|
135
|
+
If no option is provided, the first matching preset option will be automatically used.
|
|
137
136
|
- type: string
|
|
138
137
|
short: Y
|
|
139
138
|
show_config:
|
|
140
139
|
- Return the active config file path
|
|
141
140
|
- short: X
|
|
142
141
|
include_ids:
|
|
143
|
-
-
|
|
142
|
+
- Include any %{yellow:iMIS ID} and %{yellow:Ordinal} properties in returned data
|
|
144
143
|
- short: N
|
|
145
144
|
token:
|
|
146
145
|
- Provide an existing auth token
|
|
@@ -149,10 +148,10 @@ Options:
|
|
|
149
148
|
|
|
150
149
|
Logging:
|
|
151
150
|
quiet:
|
|
152
|
-
-
|
|
151
|
+
- Suppress logging to %{red:STDERR}
|
|
153
152
|
- short: q
|
|
154
153
|
log:
|
|
155
|
-
-
|
|
154
|
+
- Redirect logging to %{red:STDOUT}
|
|
156
155
|
- short: l
|
|
157
156
|
log_level:
|
|
158
157
|
- Set the logging level
|
|
@@ -8,8 +8,15 @@ module Usps
|
|
|
8
8
|
# @private
|
|
9
9
|
#
|
|
10
10
|
module OptionsParserConfig
|
|
11
|
+
STYLE_NAMES = (String.colors + String.modes).map(&:to_s).freeze
|
|
12
|
+
STYLE_PATTERN = /%\{(#{Regexp.union(STYLE_NAMES)}(?:\.#{Regexp.union(STYLE_NAMES)})*):(.*?)\}/
|
|
13
|
+
|
|
11
14
|
def subcommands
|
|
12
|
-
@subcommands ||= yaml['Subcommands'].transform_values
|
|
15
|
+
@subcommands ||= yaml['Subcommands'].transform_values do |details|
|
|
16
|
+
details.transform_keys(&:to_sym).tap do |h|
|
|
17
|
+
h[:description] = colorize_text(h[:description]) if h[:description]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
13
20
|
end
|
|
14
21
|
|
|
15
22
|
def option_groups
|
|
@@ -19,7 +26,7 @@ module Usps
|
|
|
19
26
|
def options
|
|
20
27
|
@options ||= merged_options.transform_keys(&:to_sym).transform_values do |description, details|
|
|
21
28
|
[
|
|
22
|
-
description,
|
|
29
|
+
colorize_text(description),
|
|
23
30
|
details.transform_keys(&:to_sym).each_with_object({}) do |(key, value), hash|
|
|
24
31
|
hash[key] = %i[type short].include?(key) ? value.to_sym : value
|
|
25
32
|
end
|
|
@@ -51,11 +58,18 @@ module Usps
|
|
|
51
58
|
private
|
|
52
59
|
|
|
53
60
|
def yaml
|
|
54
|
-
|
|
61
|
+
@yaml ||= YAML.safe_load_file("#{File.dirname(__FILE__)}/options.yml")
|
|
62
|
+
end
|
|
55
63
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
def colorize_text(text)
|
|
65
|
+
text.gsub(STYLE_PATTERN) { Regexp.last_match(2).colorize(style_args(Regexp.last_match(1))) }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def style_args(styles)
|
|
69
|
+
styles.split('.').each_with_object({}) do |name, args|
|
|
70
|
+
key = String.colors.include?(name.to_sym) ? :color : :mode
|
|
71
|
+
args[key] = name.to_sym
|
|
72
|
+
end
|
|
59
73
|
end
|
|
60
74
|
|
|
61
75
|
def merged_options
|
|
@@ -16,7 +16,7 @@ module Usps
|
|
|
16
16
|
'|',
|
|
17
17
|
formatted_tags,
|
|
18
18
|
'|',
|
|
19
|
-
message
|
|
19
|
+
filter(message)
|
|
20
20
|
]
|
|
21
21
|
"#{log_chunks.join(' ')}\n"
|
|
22
22
|
end
|
|
@@ -27,6 +27,13 @@ module Usps
|
|
|
27
27
|
tags = current_tags || []
|
|
28
28
|
tags&.any? ? tags.join(' | ') : ''
|
|
29
29
|
end
|
|
30
|
+
|
|
31
|
+
def filter(message)
|
|
32
|
+
message
|
|
33
|
+
.to_s
|
|
34
|
+
.sub(/^#{Regexp.escape(tags_text)}/, '')
|
|
35
|
+
.gsub(/"token": ".*?",/, '"token": "[FILTERED]",')
|
|
36
|
+
end
|
|
30
37
|
end
|
|
31
38
|
end
|
|
32
39
|
end
|
data/lib/usps/imis/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: usps-imis-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.13.
|
|
4
|
+
version: 0.13.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Julian Fiander
|
|
@@ -97,7 +97,7 @@ files:
|
|
|
97
97
|
- lib/usps/imis/command_line/formatters.rb
|
|
98
98
|
- lib/usps/imis/command_line/help.rb
|
|
99
99
|
- lib/usps/imis/command_line/interface.rb
|
|
100
|
-
- lib/usps/imis/command_line/options.yml
|
|
100
|
+
- lib/usps/imis/command_line/options.yml
|
|
101
101
|
- lib/usps/imis/command_line/options_parser.rb
|
|
102
102
|
- lib/usps/imis/command_line/options_parser_config.rb
|
|
103
103
|
- lib/usps/imis/command_line/performers.rb
|