ukiryu 0.1.1 → 0.1.3
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/.github/workflows/release.yml +58 -14
- data/.gitignore +3 -0
- data/.rubocop_todo.yml +170 -79
- data/Gemfile +1 -1
- data/README.adoc +1603 -576
- data/docs/.gitignore +1 -0
- data/docs/Gemfile +10 -0
- data/docs/INDEX.adoc +261 -0
- data/docs/_config.yml +180 -0
- data/docs/advanced/custom-tool-classes.adoc +581 -0
- data/docs/advanced/index.adoc +20 -0
- data/docs/features/configuration.adoc +657 -0
- data/docs/features/index.adoc +31 -0
- data/docs/features/platform-support.adoc +488 -0
- data/docs/getting-started/core-concepts.adoc +666 -0
- data/docs/getting-started/index.adoc +36 -0
- data/docs/getting-started/installation.adoc +216 -0
- data/docs/getting-started/quick-start.adoc +258 -0
- data/docs/guides/env-var-sets.adoc +388 -0
- data/docs/guides/index.adoc +20 -0
- data/docs/interfaces/cli.adoc +609 -0
- data/docs/interfaces/index.adoc +153 -0
- data/docs/interfaces/ruby-api.adoc +538 -0
- data/docs/lychee.toml +49 -0
- data/docs/reference/configuration-options.adoc +720 -0
- data/docs/reference/error-codes.adoc +634 -0
- data/docs/reference/index.adoc +20 -0
- data/docs/reference/ruby-api.adoc +1217 -0
- data/docs/understanding/index.adoc +20 -0
- data/lib/ukiryu/cli.rb +43 -58
- data/lib/ukiryu/cli_commands/base_command.rb +16 -27
- data/lib/ukiryu/cli_commands/cache_command.rb +100 -0
- data/lib/ukiryu/cli_commands/commands_command.rb +8 -8
- data/lib/ukiryu/cli_commands/commands_command.rb.fixed +1 -1
- data/lib/ukiryu/cli_commands/config_command.rb +49 -7
- data/lib/ukiryu/cli_commands/definitions_command.rb +254 -0
- data/lib/ukiryu/cli_commands/describe_command.rb +13 -7
- data/lib/ukiryu/cli_commands/describe_command.rb.fixed +1 -1
- data/lib/ukiryu/cli_commands/docs_command.rb +148 -0
- data/lib/ukiryu/cli_commands/exec_inline_command.rb.fixed +1 -1
- data/lib/ukiryu/cli_commands/extract_command.rb +2 -2
- data/lib/ukiryu/cli_commands/info_command.rb +7 -7
- data/lib/ukiryu/cli_commands/lint_command.rb +167 -0
- data/lib/ukiryu/cli_commands/list_command.rb +6 -6
- data/lib/ukiryu/cli_commands/opts_command.rb +2 -2
- data/lib/ukiryu/cli_commands/opts_command.rb.fixed +1 -1
- data/lib/ukiryu/cli_commands/register_command.rb +144 -0
- data/lib/ukiryu/cli_commands/resolve_command.rb +124 -0
- data/lib/ukiryu/cli_commands/run_command.rb +38 -14
- data/lib/ukiryu/cli_commands/run_file_command.rb +2 -2
- data/lib/ukiryu/cli_commands/system_command.rb +50 -32
- data/lib/ukiryu/cli_commands/validate_command.rb +452 -51
- data/lib/ukiryu/cli_commands/which_command.rb +5 -5
- data/lib/ukiryu/command_builder.rb +81 -23
- data/lib/ukiryu/config/env_provider.rb +3 -3
- data/lib/ukiryu/config/env_schema.rb +6 -6
- data/lib/ukiryu/config.rb +11 -11
- data/lib/ukiryu/definition/definition_cache.rb +238 -0
- data/lib/ukiryu/definition/definition_composer.rb +257 -0
- data/lib/ukiryu/definition/definition_linter.rb +460 -0
- data/lib/ukiryu/definition/definition_validator.rb +320 -0
- data/lib/ukiryu/definition/discovery.rb +239 -0
- data/lib/ukiryu/definition/documentation_generator.rb +429 -0
- data/lib/ukiryu/definition/lint_issue.rb +168 -0
- data/lib/ukiryu/definition/loader.rb +139 -0
- data/lib/ukiryu/definition/metadata.rb +159 -0
- data/lib/ukiryu/definition/source.rb +87 -0
- data/lib/ukiryu/definition/sources/file.rb +138 -0
- data/lib/ukiryu/definition/sources/string.rb +88 -0
- data/lib/ukiryu/definition/validation_result.rb +158 -0
- data/lib/ukiryu/definition/version_resolver.rb +194 -0
- data/lib/ukiryu/definition.rb +40 -0
- data/lib/ukiryu/errors.rb +6 -0
- data/lib/ukiryu/execution_context.rb +11 -11
- data/lib/ukiryu/executor.rb +6 -0
- data/lib/ukiryu/extractors/extractor.rb +6 -5
- data/lib/ukiryu/extractors/help_parser.rb +13 -19
- data/lib/ukiryu/logger.rb +3 -1
- data/lib/ukiryu/models/command_definition.rb +3 -3
- data/lib/ukiryu/models/command_info.rb +1 -1
- data/lib/ukiryu/models/components.rb +1 -3
- data/lib/ukiryu/models/env_var_definition.rb +11 -3
- data/lib/ukiryu/models/flag_definition.rb +15 -0
- data/lib/ukiryu/models/option_definition.rb +7 -7
- data/lib/ukiryu/models/platform_profile.rb +6 -3
- data/lib/ukiryu/models/routing.rb +1 -1
- data/lib/ukiryu/models/tool_definition.rb +2 -4
- data/lib/ukiryu/models/tool_metadata.rb +6 -6
- data/lib/ukiryu/models/validation_result.rb +1 -1
- data/lib/ukiryu/models/version_compatibility.rb +6 -3
- data/lib/ukiryu/models/version_detection.rb +10 -1
- data/lib/ukiryu/{registry.rb → register.rb} +54 -38
- data/lib/ukiryu/register_auto_manager.rb +268 -0
- data/lib/ukiryu/schema_validator.rb +31 -10
- data/lib/ukiryu/shell/base.rb +18 -0
- data/lib/ukiryu/shell/bash.rb +19 -1
- data/lib/ukiryu/shell/cmd.rb +11 -1
- data/lib/ukiryu/shell/powershell.rb +11 -1
- data/lib/ukiryu/shell.rb +1 -1
- data/lib/ukiryu/tool.rb +107 -95
- data/lib/ukiryu/tool_index.rb +22 -22
- data/lib/ukiryu/tools/base.rb +12 -25
- data/lib/ukiryu/tools/generator.rb +7 -7
- data/lib/ukiryu/tools.rb +3 -3
- data/lib/ukiryu/type.rb +20 -5
- data/lib/ukiryu/version.rb +1 -1
- data/lib/ukiryu/version_detector.rb +21 -2
- data/lib/ukiryu.rb +6 -3
- data/ukiryu-proposal.md +41 -41
- data/ukiryu.gemspec +1 -0
- metadata +64 -8
- data/.gitmodules +0 -3
|
@@ -0,0 +1,657 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Configuration Methods
|
|
4
|
+
parent: Features
|
|
5
|
+
nav_order: 1
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
== Configuration Methods
|
|
9
|
+
|
|
10
|
+
Ukiryu supports three complementary configuration methods with clear precedence rules, allowing you to customize tool behavior for any environment.
|
|
11
|
+
|
|
12
|
+
// Purpose
|
|
13
|
+
== Purpose
|
|
14
|
+
|
|
15
|
+
This page documents the three configuration methods (ENV variables, CLI parameters, and Ruby API) and their precedence rules.
|
|
16
|
+
|
|
17
|
+
// References
|
|
18
|
+
== References
|
|
19
|
+
|
|
20
|
+
* link:/interfaces/ruby-api[Ruby API Documentation]
|
|
21
|
+
* link:/interfaces/cli[CLI Documentation]
|
|
22
|
+
* link:/reference/configuration-options[Configuration Reference]
|
|
23
|
+
|
|
24
|
+
// Concepts
|
|
25
|
+
== Concepts
|
|
26
|
+
|
|
27
|
+
* **Configuration precedence**: Order in which configuration methods override each other
|
|
28
|
+
* **Global configuration**: Settings that apply to all tool executions
|
|
29
|
+
* **Per-command configuration**: Settings that apply to a single command
|
|
30
|
+
* **Type coercion**: Automatic conversion of parameter values to correct types
|
|
31
|
+
|
|
32
|
+
// Configuration Precedence
|
|
33
|
+
== Configuration Precedence
|
|
34
|
+
|
|
35
|
+
Ukiryu applies configuration in the following order (highest to lowest precedence):
|
|
36
|
+
|
|
37
|
+
[cols="1,1,4"]
|
|
38
|
+
|===
|
|
39
|
+
|Level |Method |Description
|
|
40
|
+
|
|
41
|
+
|1 (Highest)
|
|
42
|
+
|Environment Variables
|
|
43
|
+
|System-wide settings that override everything
|
|
44
|
+
|
|
45
|
+
|2
|
|
46
|
+
|CLI Parameters
|
|
47
|
+
|Command-line arguments for interactive use
|
|
48
|
+
|
|
49
|
+
|3
|
|
50
|
+
|Ruby API Parameters
|
|
51
|
+
|Programmatic settings for library usage
|
|
52
|
+
|
|
53
|
+
|4 (Lowest)
|
|
54
|
+
|Profile Defaults
|
|
55
|
+
|Default values from tool profiles
|
|
56
|
+
|===
|
|
57
|
+
|
|
58
|
+
NOTE: Higher precedence levels completely override lower levels for the same configuration option.
|
|
59
|
+
|
|
60
|
+
// Method 1: Environment Variables
|
|
61
|
+
== Environment Variables (Highest Precedence)
|
|
62
|
+
|
|
63
|
+
Environment variables provide global configuration that affects all Ukiryu operations.
|
|
64
|
+
|
|
65
|
+
=== Setting Environment Variables
|
|
66
|
+
|
|
67
|
+
[source,bash]
|
|
68
|
+
----
|
|
69
|
+
# Unix/Linux/macOS - Set in shell or .bashrc/.zshrc
|
|
70
|
+
export UKIRYU_REGISTER=/path/to/register
|
|
71
|
+
export UKIRYU_TIMEOUT=180
|
|
72
|
+
export UKIRYU_DEBUG=true
|
|
73
|
+
|
|
74
|
+
# Windows Command Prompt
|
|
75
|
+
set UKIRYU_REGISTER=C:\path\to\register
|
|
76
|
+
set UKIRYU_TIMEOUT=180
|
|
77
|
+
set UKIRYU_DEBUG=true
|
|
78
|
+
|
|
79
|
+
# Windows PowerShell
|
|
80
|
+
$env:UKIRYU_REGISTER="C:\path\to\register"
|
|
81
|
+
$env:UKIRYU_TIMEOUT="180"
|
|
82
|
+
$env:UKIRYU_DEBUG="true"
|
|
83
|
+
----
|
|
84
|
+
|
|
85
|
+
=== Available Environment Variables
|
|
86
|
+
|
|
87
|
+
[cols="1,1,3"]
|
|
88
|
+
|===
|
|
89
|
+
|Variable |Type |Description
|
|
90
|
+
|
|
91
|
+
|`UKIRYU_REGISTER`
|
|
92
|
+
|Path
|
|
93
|
+
|Location of tool profiles directory
|
|
94
|
+
|
|
95
|
+
|`UKIRYU_TIMEOUT`
|
|
96
|
+
|Integer
|
|
97
|
+
|Default execution timeout in seconds
|
|
98
|
+
|
|
99
|
+
|`UKIRYU_DEBUG`
|
|
100
|
+
|Boolean
|
|
101
|
+
|Enable debug output (true/false)
|
|
102
|
+
|
|
103
|
+
|`UKIRYU_LOG_LEVEL`
|
|
104
|
+
|Symbol
|
|
105
|
+
|Logging level (:debug, :info, :warn, :error)
|
|
106
|
+
|
|
107
|
+
|`UKIRYU_SHELL`
|
|
108
|
+
|Symbol
|
|
109
|
+
|Shell to use for command execution (:bash, :zsh, :fish, :sh, :powershell, :cmd)
|
|
110
|
+
|
|
111
|
+
|`UKIRYU_COLOR`
|
|
112
|
+
|Boolean
|
|
113
|
+
|Enable colored output (true/false)
|
|
114
|
+
|===
|
|
115
|
+
|
|
116
|
+
=== Environment Variable Examples
|
|
117
|
+
|
|
118
|
+
[source,ruby]
|
|
119
|
+
----
|
|
120
|
+
# Ruby API - ENV variables take precedence
|
|
121
|
+
ENV['UKIRYU_TIMEOUT'] = '180'
|
|
122
|
+
|
|
123
|
+
require 'ukiryu'
|
|
124
|
+
tool = Ukiryu::Tool.get(:inkscape)
|
|
125
|
+
|
|
126
|
+
# This uses 180 second timeout from ENV, not the 60 second parameter
|
|
127
|
+
result = tool.execute(:export, {
|
|
128
|
+
inputs: ['drawing.svg'],
|
|
129
|
+
output: 'drawing.png'
|
|
130
|
+
}, timeout: 60)
|
|
131
|
+
----
|
|
132
|
+
|
|
133
|
+
[source,bash]
|
|
134
|
+
----
|
|
135
|
+
# CLI - ENV variables override CLI parameters
|
|
136
|
+
export UKIRYU_TIMEOUT=180
|
|
137
|
+
|
|
138
|
+
ukiryu exec inkscape export \
|
|
139
|
+
inputs=drawing.svg \
|
|
140
|
+
output=drawing.png \
|
|
141
|
+
timeout=60 # Ignored - ENV wins
|
|
142
|
+
----
|
|
143
|
+
|
|
144
|
+
// Method 2: CLI Parameters
|
|
145
|
+
== CLI Parameters (Medium Precedence)
|
|
146
|
+
|
|
147
|
+
CLI parameters provide per-command configuration for interactive use.
|
|
148
|
+
|
|
149
|
+
=== Basic Syntax
|
|
150
|
+
|
|
151
|
+
[source,bash]
|
|
152
|
+
----
|
|
153
|
+
ukiryu exec <tool> <command> [KEY=VALUE ...]
|
|
154
|
+
----
|
|
155
|
+
|
|
156
|
+
=== Parameter Examples
|
|
157
|
+
|
|
158
|
+
[source,bash]
|
|
159
|
+
----
|
|
160
|
+
# Set timeout for this command
|
|
161
|
+
ukiryu exec inkscape export \
|
|
162
|
+
inputs=drawing.svg \
|
|
163
|
+
output=drawing.png \
|
|
164
|
+
timeout=120
|
|
165
|
+
|
|
166
|
+
# Set multiple parameters
|
|
167
|
+
ukiryu exec imagemagick convert \
|
|
168
|
+
inputs=photo.jpg \
|
|
169
|
+
output=photo.png \
|
|
170
|
+
resize=50% \
|
|
171
|
+
quality=85 \
|
|
172
|
+
timeout=60
|
|
173
|
+
----
|
|
174
|
+
|
|
175
|
+
=== Global CLI Options
|
|
176
|
+
|
|
177
|
+
[source,bash]
|
|
178
|
+
----
|
|
179
|
+
# Override register location
|
|
180
|
+
ukiryu --register /path/to/register exec inkscape export inputs=drawing.svg output=drawing.png
|
|
181
|
+
|
|
182
|
+
# Set timeout
|
|
183
|
+
ukiryu --timeout 120 exec inkscape export inputs=drawing.svg output=drawing.png
|
|
184
|
+
|
|
185
|
+
# Enable debug output
|
|
186
|
+
ukiryu --debug exec inkscape export inputs=drawing.svg output=drawing.png
|
|
187
|
+
----
|
|
188
|
+
|
|
189
|
+
// Method 3: Ruby API Parameters
|
|
190
|
+
== Ruby API Parameters (Lowest Precedence)
|
|
191
|
+
|
|
192
|
+
Ruby API parameters provide programmatic configuration for library usage.
|
|
193
|
+
|
|
194
|
+
=== Basic Syntax
|
|
195
|
+
|
|
196
|
+
[source,ruby]
|
|
197
|
+
----
|
|
198
|
+
result = tool.execute(:command, {
|
|
199
|
+
param1: value1,
|
|
200
|
+
param2: value2
|
|
201
|
+
}, {
|
|
202
|
+
option1: value1 # Execution options
|
|
203
|
+
})
|
|
204
|
+
----
|
|
205
|
+
|
|
206
|
+
=== Parameter Examples
|
|
207
|
+
|
|
208
|
+
[source,ruby]
|
|
209
|
+
----
|
|
210
|
+
# Command parameters
|
|
211
|
+
result = tool.execute(:export, {
|
|
212
|
+
inputs: ['drawing.svg'],
|
|
213
|
+
output: 'drawing.png',
|
|
214
|
+
format: :png,
|
|
215
|
+
dpi: 300
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
# Execution options
|
|
219
|
+
result = tool.execute(:export, params, {
|
|
220
|
+
timeout: 60,
|
|
221
|
+
allow_failure: true,
|
|
222
|
+
cwd: '/path/to/directory'
|
|
223
|
+
})
|
|
224
|
+
----
|
|
225
|
+
|
|
226
|
+
=== Configuration Methods
|
|
227
|
+
|
|
228
|
+
[source,ruby]
|
|
229
|
+
----
|
|
230
|
+
# Set register path
|
|
231
|
+
Ukiryu::Register.default_register_path = '/path/to/register'
|
|
232
|
+
|
|
233
|
+
# Set default timeout
|
|
234
|
+
Ukiryu::Executor::DEFAULT_TIMEOUT = 120
|
|
235
|
+
|
|
236
|
+
# Enable debug mode
|
|
237
|
+
Ukiryu::Config.debug = true
|
|
238
|
+
----
|
|
239
|
+
|
|
240
|
+
// Precedence Examples
|
|
241
|
+
== Precedence Examples
|
|
242
|
+
|
|
243
|
+
=== Example 1: Timeout Configuration
|
|
244
|
+
|
|
245
|
+
[source,ruby]
|
|
246
|
+
----
|
|
247
|
+
# Profile default: 90 seconds
|
|
248
|
+
# Ruby API parameter: 60 seconds
|
|
249
|
+
# CLI parameter: 120 seconds
|
|
250
|
+
# ENV variable: 180 seconds (wins!)
|
|
251
|
+
|
|
252
|
+
# Set ENV
|
|
253
|
+
ENV['UKIRYU_TIMEOUT'] = '180'
|
|
254
|
+
|
|
255
|
+
# Ruby code
|
|
256
|
+
require 'ukiryu'
|
|
257
|
+
tool = Ukiryu::Tool.get(:inkscape)
|
|
258
|
+
|
|
259
|
+
# CLI would use 120, but ENV wins
|
|
260
|
+
result = tool.execute(:export, {
|
|
261
|
+
inputs: ['drawing.svg'],
|
|
262
|
+
output: 'drawing.png'
|
|
263
|
+
}, timeout: 60)
|
|
264
|
+
|
|
265
|
+
# Result: Uses 180 second timeout from ENV
|
|
266
|
+
----
|
|
267
|
+
|
|
268
|
+
=== Example 2: Register Configuration
|
|
269
|
+
|
|
270
|
+
[source,ruby]
|
|
271
|
+
----
|
|
272
|
+
# Method 1: ENV (highest)
|
|
273
|
+
ENV['UKIRYU_REGISTER'] = '/custom/register'
|
|
274
|
+
|
|
275
|
+
# Method 2: CLI flag
|
|
276
|
+
ukiryu --register /custom/list exec inkscape export ...
|
|
277
|
+
|
|
278
|
+
# Method 3: Ruby API
|
|
279
|
+
Ukiryu::Register.default_register_path = '/custom/register'
|
|
280
|
+
|
|
281
|
+
# Method 4: Automatic discovery
|
|
282
|
+
# ~/.ukiryu/register (auto-cloned if needed)
|
|
283
|
+
----
|
|
284
|
+
|
|
285
|
+
=== Example 3: Complete Configuration Stack
|
|
286
|
+
|
|
287
|
+
[source,ruby]
|
|
288
|
+
----
|
|
289
|
+
# 1. Profile default: timeout=90
|
|
290
|
+
# 2. Ruby API setting: timeout=60
|
|
291
|
+
# 3. CLI parameter: timeout=120
|
|
292
|
+
# 4. ENV variable: timeout=180 (FINAL VALUE)
|
|
293
|
+
|
|
294
|
+
# Configure globally via Ruby API
|
|
295
|
+
Ukiryu::Executor::DEFAULT_TIMEOUT = 60
|
|
296
|
+
|
|
297
|
+
# Set ENV to override
|
|
298
|
+
ENV['UKIRYU_TIMEOUT'] = '180'
|
|
299
|
+
|
|
300
|
+
# Execute
|
|
301
|
+
tool = Ukiryu::Tool.get(:inkscape)
|
|
302
|
+
result = tool.execute(:export, params, timeout: 60)
|
|
303
|
+
|
|
304
|
+
# ENV (180) > CLI parameter (120) > Ruby API parameter (60) > default (90)
|
|
305
|
+
# Result: Uses 180 seconds
|
|
306
|
+
----
|
|
307
|
+
|
|
308
|
+
// Configuration Comparison
|
|
309
|
+
== Configuration Comparison
|
|
310
|
+
|
|
311
|
+
=== By Use Case
|
|
312
|
+
|
|
313
|
+
[cols="1,1,4"]
|
|
314
|
+
|===
|
|
315
|
+
|Use Case |Best Method |Example
|
|
316
|
+
|
|
317
|
+
|CI/CD pipelines
|
|
318
|
+
|Environment Variables
|
|
319
|
+
|Set `UKIRYU_TIMEOUT` in GitHub Actions
|
|
320
|
+
|
|
321
|
+
|Production applications
|
|
322
|
+
|Ruby API
|
|
323
|
+
|Configure in application code
|
|
324
|
+
|
|
325
|
+
|Interactive scripts
|
|
326
|
+
|CLI Parameters
|
|
327
|
+
|Pass options on command line
|
|
328
|
+
|
|
329
|
+
|Development
|
|
330
|
+
|Ruby API
|
|
331
|
+
|Set in test/fixtures or config files
|
|
332
|
+
|
|
333
|
+
|Debugging
|
|
334
|
+
|Environment Variables
|
|
335
|
+
|Set `UKIRYU_DEBUG=true`
|
|
336
|
+
|
|
337
|
+
|One-off commands
|
|
338
|
+
|CLI Parameters
|
|
339
|
+
|Specify directly in shell
|
|
340
|
+
|===
|
|
341
|
+
|
|
342
|
+
=== By Configuration Type
|
|
343
|
+
|
|
344
|
+
[cols="1,1,2,1"]
|
|
345
|
+
|===
|
|
346
|
+
|Setting |ENV |CLI |Ruby API
|
|
347
|
+
|
|
348
|
+
|Register location
|
|
349
|
+
|✓ `UKIRYU_REGISTER`
|
|
350
|
+
|✓ `--register PATH`
|
|
351
|
+
|✓ `Register.default_register_path=`
|
|
352
|
+
|
|
353
|
+
|Timeout
|
|
354
|
+
|✓ `UKIRYU_TIMEOUT`
|
|
355
|
+
|✓ `--timeout SECONDS`
|
|
356
|
+
|✓ `timeout: SECONDS`
|
|
357
|
+
|
|
358
|
+
|Debug output
|
|
359
|
+
|✓ `UKIRYU_DEBUG`
|
|
360
|
+
|✓ `--debug`
|
|
361
|
+
|✓ `Config.debug = true`
|
|
362
|
+
|
|
363
|
+
|Shell
|
|
364
|
+
|✓ `UKIRYU_SHELL`
|
|
365
|
+
|✓ `--shell SHELL`
|
|
366
|
+
|✓ `Config.shell = :bash`
|
|
367
|
+
|
|
368
|
+
|Working directory
|
|
369
|
+
|✓ `UKIRYU_CWD`
|
|
370
|
+
|N/A
|
|
371
|
+
|✓ `cwd: '/path'`
|
|
372
|
+
|
|
373
|
+
|Allow failure
|
|
374
|
+
|N/A
|
|
375
|
+
|N/A
|
|
376
|
+
|✓ `allow_failure: true`
|
|
377
|
+
|===
|
|
378
|
+
|
|
379
|
+
// Type Coercion
|
|
380
|
+
== Type Coercion
|
|
381
|
+
|
|
382
|
+
All configuration methods support automatic type coercion.
|
|
383
|
+
|
|
384
|
+
=== String Values
|
|
385
|
+
|
|
386
|
+
[source,bash]
|
|
387
|
+
----
|
|
388
|
+
# ENV - Always strings
|
|
389
|
+
export UKIRYU_TIMEOUT="180"
|
|
390
|
+
----
|
|
391
|
+
|
|
392
|
+
[source,ruby]
|
|
393
|
+
----
|
|
394
|
+
# CLI - String values, auto-coerced
|
|
395
|
+
ukiryu exec inkscape export timeout=180
|
|
396
|
+
|
|
397
|
+
# Ruby API - Native types
|
|
398
|
+
tool.execute(:export, params, timeout: 180) # Integer
|
|
399
|
+
----
|
|
400
|
+
|
|
401
|
+
=== Boolean Values
|
|
402
|
+
|
|
403
|
+
[source,bash]
|
|
404
|
+
----
|
|
405
|
+
# ENV - String "true"/"false"
|
|
406
|
+
export UKIRYU_DEBUG="true"
|
|
407
|
+
----
|
|
408
|
+
|
|
409
|
+
[source,ruby]
|
|
410
|
+
----
|
|
411
|
+
# CLI - No value needed
|
|
412
|
+
ukiryu --debug exec inkscape export ...
|
|
413
|
+
|
|
414
|
+
# Ruby API - Boolean
|
|
415
|
+
Ukiryu::Config.debug = true
|
|
416
|
+
----
|
|
417
|
+
|
|
418
|
+
=== Symbol Values
|
|
419
|
+
|
|
420
|
+
[source,bash]
|
|
421
|
+
----
|
|
422
|
+
# CLI - Colon prefix
|
|
423
|
+
ukiryu exec inkscape export format=:png
|
|
424
|
+
----
|
|
425
|
+
|
|
426
|
+
[source,ruby]
|
|
427
|
+
----
|
|
428
|
+
# Ruby API - Native symbols
|
|
429
|
+
tool.execute(:export, { format: :png })
|
|
430
|
+
----
|
|
431
|
+
|
|
432
|
+
=== Array Values
|
|
433
|
+
|
|
434
|
+
[source,bash]
|
|
435
|
+
----
|
|
436
|
+
# CLI - Comma-separated
|
|
437
|
+
ukiryu exec inkscape export export_ids=id1,id2,id3
|
|
438
|
+
----
|
|
439
|
+
|
|
440
|
+
[source,ruby]
|
|
441
|
+
----
|
|
442
|
+
# Ruby API - Array
|
|
443
|
+
tool.execute(:export, { export_ids: ['id1', 'id2', 'id3'] })
|
|
444
|
+
----
|
|
445
|
+
|
|
446
|
+
// Shell Configuration
|
|
447
|
+
== Shell Configuration
|
|
448
|
+
|
|
449
|
+
Ukiryu automatically detects the appropriate shell for your platform, but you can explicitly specify which shell to use for command execution.
|
|
450
|
+
|
|
451
|
+
=== Available Shells
|
|
452
|
+
|
|
453
|
+
Supported shells vary by platform:
|
|
454
|
+
|
|
455
|
+
[cols="1,1"]
|
|
456
|
+
|===
|
|
457
|
+
|Platform |Available Shells
|
|
458
|
+
|
|
459
|
+
|macOS/Linux
|
|
460
|
+
|bash, zsh, fish, sh
|
|
461
|
+
|
|
462
|
+
|Windows
|
|
463
|
+
|powershell, cmd, bash (Git Bash/MSYS)
|
|
464
|
+
|===
|
|
465
|
+
|
|
466
|
+
=== Configuration Methods
|
|
467
|
+
|
|
468
|
+
==== Via Environment Variable
|
|
469
|
+
|
|
470
|
+
Set the shell for all commands:
|
|
471
|
+
|
|
472
|
+
[source,bash]
|
|
473
|
+
----
|
|
474
|
+
# Unix/Linux/macOS
|
|
475
|
+
export UKIRYU_SHELL=zsh
|
|
476
|
+
|
|
477
|
+
# Windows PowerShell
|
|
478
|
+
$env:UKIRYU_SHELL="zsh"
|
|
479
|
+
|
|
480
|
+
# All subsequent commands use zsh
|
|
481
|
+
ukiryu exec inkscape export inputs=input.svg output=output.png
|
|
482
|
+
----
|
|
483
|
+
|
|
484
|
+
==== Via CLI Option
|
|
485
|
+
|
|
486
|
+
Override the shell for a specific command:
|
|
487
|
+
|
|
488
|
+
[source,bash]
|
|
489
|
+
----
|
|
490
|
+
# Long form
|
|
491
|
+
ukiryu exec inkscape export inputs=input.svg output=output.png --shell zsh
|
|
492
|
+
|
|
493
|
+
# Short form
|
|
494
|
+
ukiryu exec inkscape export inputs=input.svg output=output.png -s zsh
|
|
495
|
+
|
|
496
|
+
# Check available shells on your system
|
|
497
|
+
ukiryu system shells
|
|
498
|
+
----
|
|
499
|
+
|
|
500
|
+
==== Via Ruby API
|
|
501
|
+
|
|
502
|
+
Configure the shell programmatically:
|
|
503
|
+
|
|
504
|
+
[source,ruby]
|
|
505
|
+
----
|
|
506
|
+
# Global configuration
|
|
507
|
+
Ukiryu::Config.configure do |config|
|
|
508
|
+
config.shell = :zsh
|
|
509
|
+
end
|
|
510
|
+
|
|
511
|
+
tool = Ukiryu::Tool.get(:inkscape)
|
|
512
|
+
result = tool.execute(:export, {
|
|
513
|
+
inputs: ['input.svg'],
|
|
514
|
+
output: 'output.png',
|
|
515
|
+
format: :png
|
|
516
|
+
})
|
|
517
|
+
|
|
518
|
+
# Per-execution override
|
|
519
|
+
result = tool.execute(:export, {
|
|
520
|
+
inputs: ['input.svg'],
|
|
521
|
+
output: 'output.png'
|
|
522
|
+
}, shell: :zsh)
|
|
523
|
+
----
|
|
524
|
+
|
|
525
|
+
=== Shell Auto-Detection
|
|
526
|
+
|
|
527
|
+
When no shell is explicitly configured, Ukiryu detects the shell automatically:
|
|
528
|
+
|
|
529
|
+
[source,ruby]
|
|
530
|
+
----
|
|
531
|
+
# Unix/Linux/macOS detection
|
|
532
|
+
# 1. Checks SHELL environment variable
|
|
533
|
+
# 2. Falls back to platform default
|
|
534
|
+
|
|
535
|
+
# Windows detection
|
|
536
|
+
# 1. Checks for PowerShell (PSModulePath)
|
|
537
|
+
# 2. Checks for Git Bash/MSYS (MSYSTEM, MINGW_PREFIX)
|
|
538
|
+
# 3. Falls back to cmd
|
|
539
|
+
----
|
|
540
|
+
|
|
541
|
+
=== Use Cases
|
|
542
|
+
|
|
543
|
+
==== Cross-Platform Scripts
|
|
544
|
+
|
|
545
|
+
Ensure consistent behavior across platforms:
|
|
546
|
+
|
|
547
|
+
[source,ruby]
|
|
548
|
+
----
|
|
549
|
+
# Explicitly use bash for consistent quoting on all platforms
|
|
550
|
+
Ukiryu::Config.configure do |config|
|
|
551
|
+
config.shell = :bash
|
|
552
|
+
end
|
|
553
|
+
----
|
|
554
|
+
|
|
555
|
+
==== Testing in Different Shells
|
|
556
|
+
|
|
557
|
+
Test how commands are formatted for different shells:
|
|
558
|
+
|
|
559
|
+
[source,bash]
|
|
560
|
+
----
|
|
561
|
+
# Test with bash
|
|
562
|
+
ukiryu -s bash exec imagemagick convert inputs=input.jpg output=output.png
|
|
563
|
+
|
|
564
|
+
# Test with zsh
|
|
565
|
+
ukiryu -s zsh exec imagemagick convert inputs=input.jpg output=output.png
|
|
566
|
+
|
|
567
|
+
# Test with powershell
|
|
568
|
+
ukiryu -s powershell exec imagemagick convert inputs=input.jpg output=output.png
|
|
569
|
+
----
|
|
570
|
+
|
|
571
|
+
==== CI/CD Environments
|
|
572
|
+
|
|
573
|
+
Force a specific shell in automated environments:
|
|
574
|
+
|
|
575
|
+
[source,yaml]
|
|
576
|
+
----
|
|
577
|
+
# .github/workflows/test.yml
|
|
578
|
+
env:
|
|
579
|
+
UKIRYU_SHELL: bash # Force bash for consistent behavior
|
|
580
|
+
----
|
|
581
|
+
|
|
582
|
+
// Best Practices
|
|
583
|
+
== Best Practices
|
|
584
|
+
|
|
585
|
+
=== For CI/CD
|
|
586
|
+
|
|
587
|
+
Use environment variables for consistent behavior:
|
|
588
|
+
|
|
589
|
+
[source,yaml]
|
|
590
|
+
----
|
|
591
|
+
# .github/workflows/test.yml
|
|
592
|
+
env:
|
|
593
|
+
UKIRYU_REGISTER: ./register
|
|
594
|
+
UKIRYU_TIMEOUT: 180
|
|
595
|
+
UKIRYU_DEBUG: true
|
|
596
|
+
|
|
597
|
+
steps:
|
|
598
|
+
- name: Run tests
|
|
599
|
+
run: bundle exec rspec
|
|
600
|
+
----
|
|
601
|
+
|
|
602
|
+
=== For Applications
|
|
603
|
+
|
|
604
|
+
Use Ruby API configuration in application code:
|
|
605
|
+
|
|
606
|
+
[source,ruby]
|
|
607
|
+
----
|
|
608
|
+
# config/initializers/ukiryu.rb
|
|
609
|
+
if Rails.env.production?
|
|
610
|
+
Ukiryu::Executor::DEFAULT_TIMEOUT = 180
|
|
611
|
+
else
|
|
612
|
+
Ukiryu::Executor::DEFAULT_TIMEOUT = 60
|
|
613
|
+
end
|
|
614
|
+
|
|
615
|
+
Ukiryu::Register.default_register_path = Rails.root.join('vendor', 'register')
|
|
616
|
+
----
|
|
617
|
+
|
|
618
|
+
=== For Scripts
|
|
619
|
+
|
|
620
|
+
Use CLI parameters for flexibility:
|
|
621
|
+
|
|
622
|
+
[source,bash]
|
|
623
|
+
----
|
|
624
|
+
#!/bin/bash
|
|
625
|
+
# script.sh
|
|
626
|
+
|
|
627
|
+
REGISTER=${UKIRYU_REGISTER:-"./register"}
|
|
628
|
+
TIMEOUT=${UKIRYU_TIMEOUT:-"60"}
|
|
629
|
+
|
|
630
|
+
ukiryu --register "$REGISTER" exec inkscape export \
|
|
631
|
+
inputs=drawing.svg \
|
|
632
|
+
output=drawing.png \
|
|
633
|
+
timeout="$TIMEOUT"
|
|
634
|
+
----
|
|
635
|
+
|
|
636
|
+
=== For Development
|
|
637
|
+
|
|
638
|
+
Use Ruby API in test code:
|
|
639
|
+
|
|
640
|
+
[source,ruby]
|
|
641
|
+
----
|
|
642
|
+
# spec/spec_helper.rb
|
|
643
|
+
RSpec.configure do |config|
|
|
644
|
+
# Use test register
|
|
645
|
+
Ukiryu::Register.default_register_path = 'spec/fixtures/register'
|
|
646
|
+
|
|
647
|
+
# Short timeout for tests
|
|
648
|
+
Ukiryu::Executor::DEFAULT_TIMEOUT = 10
|
|
649
|
+
end
|
|
650
|
+
----
|
|
651
|
+
|
|
652
|
+
// See Also
|
|
653
|
+
== See Also
|
|
654
|
+
|
|
655
|
+
* link:/interfaces/ruby-api[Ruby API] - Programmatic configuration
|
|
656
|
+
* link:/interfaces/cli[CLI] - Command-line configuration
|
|
657
|
+
* link:/reference/configuration-options[Complete Configuration Reference]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Features
|
|
4
|
+
nav_order: 4
|
|
5
|
+
has_children: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
= Features
|
|
9
|
+
|
|
10
|
+
Ukiryu provides powerful features for cross-platform tool execution, including multiple configuration methods, headless mode support, and comprehensive platform adaptation.
|
|
11
|
+
|
|
12
|
+
// Overview
|
|
13
|
+
== Overview
|
|
14
|
+
|
|
15
|
+
Key features that make Ukiryu suitable for production use:
|
|
16
|
+
|
|
17
|
+
* **Multiple Configuration Methods** - ENV, CLI, and Ruby API with clear precedence
|
|
18
|
+
* **Headless Mode** - GUI-free execution for tools like Inkscape
|
|
19
|
+
* **Platform Adaptation** - Automatic handling of macOS, Linux, and Windows differences
|
|
20
|
+
* **Type Safety** - Parameter validation with automatic type coercion
|
|
21
|
+
* **Structured Results** - Rich result objects with metadata and error information
|
|
22
|
+
* **Shell Awareness** - Proper quoting and escaping for all major shells
|
|
23
|
+
|
|
24
|
+
// Featured Topics
|
|
25
|
+
== Featured Topics
|
|
26
|
+
|
|
27
|
+
* link:/features/configuration[Configuration Methods] - Three ways to configure Ukiryu
|
|
28
|
+
* link:/features/headless-mode[Headless Mode] - GUI-free execution for graphics tools
|
|
29
|
+
* link:/features/platform-support[Platform Support] - Cross-platform compatibility
|
|
30
|
+
* link:/features/type-system[Type System] - Parameter validation and coercion
|
|
31
|
+
* link:/features/error-handling[Error Handling] - Structured error information
|