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,666 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Core Concepts
|
|
4
|
+
parent: Getting Started
|
|
5
|
+
nav_order: 3
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
== Core Concepts
|
|
9
|
+
|
|
10
|
+
Understanding the fundamental concepts behind Ukiryu.
|
|
11
|
+
|
|
12
|
+
// Purpose
|
|
13
|
+
== Purpose
|
|
14
|
+
|
|
15
|
+
This page explains the core concepts that power Ukiryu: Tool, Route, Action, Options/Flags, Shell, and Platform.
|
|
16
|
+
|
|
17
|
+
// References
|
|
18
|
+
== References
|
|
19
|
+
|
|
20
|
+
* link:/understanding/architecture[Architecture & Internals]
|
|
21
|
+
* link:/reference/tool-profile-schema[Tool Profile Schema]
|
|
22
|
+
* link:/advanced/writing-profiles[Writing Tool Profiles]
|
|
23
|
+
|
|
24
|
+
// Core Concepts Overview
|
|
25
|
+
== Core Concepts Overview
|
|
26
|
+
|
|
27
|
+
Ukiryu is built around these fundamental concepts:
|
|
28
|
+
|
|
29
|
+
* **Tool**: Wrapper for external CLI tools with YAML-based configuration
|
|
30
|
+
* **Route**: Maps command names to executable targets (enables multi-level hierarchies)
|
|
31
|
+
* **Action**: Specific operations within tools (formerly called "commands")
|
|
32
|
+
* **Option/Flag**: Command-line parameters with type validation
|
|
33
|
+
* **Shell**: Platform-specific command formatting (bash, zsh, fish, PowerShell, cmd)
|
|
34
|
+
* **Platform**: OS detection (macOS, Linux, Windows)
|
|
35
|
+
|
|
36
|
+
=== Concept Hierarchy
|
|
37
|
+
|
|
38
|
+
----
|
|
39
|
+
Tool
|
|
40
|
+
├── Route (maps "remote" → git-remote executable)
|
|
41
|
+
│ └── Action ("add" belongs to "remote")
|
|
42
|
+
│ ├── Arguments
|
|
43
|
+
│ ├── Options
|
|
44
|
+
│ └── Flags
|
|
45
|
+
├── Shell (bash, zsh, PowerShell, etc.)
|
|
46
|
+
└── Platform (macOS, Linux, Windows)
|
|
47
|
+
----
|
|
48
|
+
|
|
49
|
+
// Tool
|
|
50
|
+
== Tool
|
|
51
|
+
|
|
52
|
+
A **Tool** is the main wrapper class for external command-line tools. It provides a Ruby interface to CLI tools defined in YAML profiles.
|
|
53
|
+
|
|
54
|
+
=== What a Tool Does
|
|
55
|
+
|
|
56
|
+
* Loads YAML profiles from the Register
|
|
57
|
+
* Finds compatible profile based on platform/shell/version
|
|
58
|
+
* Discovers executables via custom search paths + PATH
|
|
59
|
+
* Caches instances by `{name}-{platform}-{shell}-{version}` key for performance
|
|
60
|
+
* Validates types and formats command arguments correctly
|
|
61
|
+
|
|
62
|
+
=== Tool APIs
|
|
63
|
+
|
|
64
|
+
==== Traditional API (Backward Compatible)
|
|
65
|
+
|
|
66
|
+
[source,ruby]
|
|
67
|
+
----
|
|
68
|
+
# Get a tool instance
|
|
69
|
+
tool = Ukiryu::Tool.get(:imagemagick)
|
|
70
|
+
|
|
71
|
+
# Execute an action
|
|
72
|
+
result = tool.execute(:convert, {
|
|
73
|
+
inputs: ['image.png'],
|
|
74
|
+
resize: '50%',
|
|
75
|
+
output: 'output.jpg'
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
# Access result
|
|
79
|
+
puts result.output.stdout
|
|
80
|
+
puts result.metadata.duration
|
|
81
|
+
----
|
|
82
|
+
|
|
83
|
+
==== Modern OOP API (Recommended)
|
|
84
|
+
|
|
85
|
+
[source,ruby]
|
|
86
|
+
----
|
|
87
|
+
# Create tool instance
|
|
88
|
+
tool = Ukiryu::Tools::Imagemagick.new
|
|
89
|
+
|
|
90
|
+
# Get options for an action
|
|
91
|
+
convert_options = tool.options_for(:convert)
|
|
92
|
+
convert_options.set(
|
|
93
|
+
inputs: ['image.png'],
|
|
94
|
+
resize: '50%'
|
|
95
|
+
)
|
|
96
|
+
convert_options.output = 'output.jpg'
|
|
97
|
+
|
|
98
|
+
# Run
|
|
99
|
+
convert_options.run
|
|
100
|
+
----
|
|
101
|
+
|
|
102
|
+
=== Tool Discovery
|
|
103
|
+
|
|
104
|
+
Tools are discovered from the Register in this order:
|
|
105
|
+
|
|
106
|
+
1. `UKIRYU_REGISTER` environment variable
|
|
107
|
+
2. `~/.ukiryu/register` (auto-cloned on first use)
|
|
108
|
+
|
|
109
|
+
// Route
|
|
110
|
+
== Route
|
|
111
|
+
|
|
112
|
+
A **Route** maps command names to their executable targets, enabling hierarchical tools like `git remote` where the command routes to the `git-remote` executable.
|
|
113
|
+
|
|
114
|
+
=== How Routing Works
|
|
115
|
+
|
|
116
|
+
* **Single-level routing**: `tool remote` → `git-remote` executable
|
|
117
|
+
* **Multi-level routing**: `tool remote add` → nested command structure
|
|
118
|
+
* **O(1) lookup** via routing table for performance
|
|
119
|
+
|
|
120
|
+
=== Routing Table Example
|
|
121
|
+
|
|
122
|
+
[source,yaml]
|
|
123
|
+
----
|
|
124
|
+
# tools/git/2.30.yaml
|
|
125
|
+
name: git
|
|
126
|
+
version: '2.30'
|
|
127
|
+
|
|
128
|
+
routing:
|
|
129
|
+
remote: git-remote # Maps "remote" to git-remote command
|
|
130
|
+
branch: git-branch # Maps "branch" to git-branch command
|
|
131
|
+
stash: git-stash # Maps "stash" to git-stash command
|
|
132
|
+
tag: git-tag # Maps "tag" to git-tag command
|
|
133
|
+
----
|
|
134
|
+
|
|
135
|
+
=== Resolving Routes
|
|
136
|
+
|
|
137
|
+
[source,ruby]
|
|
138
|
+
----
|
|
139
|
+
# Resolve single command
|
|
140
|
+
routing.resolve('remote') # => 'git-remote'
|
|
141
|
+
|
|
142
|
+
# Multi-level routing
|
|
143
|
+
routing.resolve_path(['remote', 'add'])
|
|
144
|
+
# => ['git-remote', 'action']
|
|
145
|
+
----
|
|
146
|
+
|
|
147
|
+
=== Child Routing Tables
|
|
148
|
+
|
|
149
|
+
Commands can have their own child routing tables for nested hierarchies:
|
|
150
|
+
|
|
151
|
+
[source,yaml]
|
|
152
|
+
----
|
|
153
|
+
commands:
|
|
154
|
+
- name: remote
|
|
155
|
+
routing:
|
|
156
|
+
add: git-remote-add
|
|
157
|
+
remove: git-remote-remove
|
|
158
|
+
prune: git-remote-prune
|
|
159
|
+
----
|
|
160
|
+
|
|
161
|
+
// Action
|
|
162
|
+
== Action
|
|
163
|
+
|
|
164
|
+
An **Action** is a specific operation within a tool (formerly called "commands"). Actions represent individual operations that can be executed.
|
|
165
|
+
|
|
166
|
+
=== Actions vs Routes
|
|
167
|
+
|
|
168
|
+
| Aspect | Route | Action |
|
|
169
|
+
|===
|
|
170
|
+
|*Purpose* | Maps command names to executables | Specific operations to execute |
|
|
171
|
+
|*Example* | `remote` → `git-remote` | `add` in `git remote add` |
|
|
172
|
+
|*Hierarchy* | Top-level mapping | Can belong to parent commands |
|
|
173
|
+
|*Syntax* | Defined in `routing:` table | Defined in `commands:` list |
|
|
174
|
+
|===}
|
|
175
|
+
|
|
176
|
+
=== Action Types
|
|
177
|
+
|
|
178
|
+
==== Standalone Actions
|
|
179
|
+
|
|
180
|
+
[source,yaml]
|
|
181
|
+
----
|
|
182
|
+
commands:
|
|
183
|
+
- name: export
|
|
184
|
+
description: Export document to different format
|
|
185
|
+
arguments:
|
|
186
|
+
- name: inputs
|
|
187
|
+
type: file
|
|
188
|
+
variadic: true
|
|
189
|
+
position: last
|
|
190
|
+
----
|
|
191
|
+
|
|
192
|
+
==== Hierarchical Actions (with `belongs_to`)
|
|
193
|
+
|
|
194
|
+
[source,yaml]
|
|
195
|
+
----
|
|
196
|
+
commands:
|
|
197
|
+
- name: remote
|
|
198
|
+
description: Manage remote repositories
|
|
199
|
+
|
|
200
|
+
- name: add
|
|
201
|
+
description: Add remote repository
|
|
202
|
+
belongs_to: remote # Belongs to "remote" parent
|
|
203
|
+
cli_flag: -a # Can be invoked as flag
|
|
204
|
+
arguments:
|
|
205
|
+
- name: name
|
|
206
|
+
type: string
|
|
207
|
+
required: true
|
|
208
|
+
- name: url
|
|
209
|
+
type: string
|
|
210
|
+
required: true
|
|
211
|
+
----
|
|
212
|
+
|
|
213
|
+
This creates: `git remote add <name> <url>`
|
|
214
|
+
|
|
215
|
+
==== Flag-Based Actions
|
|
216
|
+
|
|
217
|
+
[source,yaml]
|
|
218
|
+
----
|
|
219
|
+
commands:
|
|
220
|
+
- name: branch
|
|
221
|
+
description: Manage branches
|
|
222
|
+
|
|
223
|
+
- name: delete
|
|
224
|
+
description: Delete a branch
|
|
225
|
+
belongs_to: branch
|
|
226
|
+
cli_flag: -d # Invoked as: git branch -d
|
|
227
|
+
----
|
|
228
|
+
|
|
229
|
+
=== Action Features
|
|
230
|
+
|
|
231
|
+
* **Aliases**: Alternative names for actions
|
|
232
|
+
* **Subcommands**: Multi-word commands like `storage account create`
|
|
233
|
+
* **CLI Flags**: Actions invoked as flags (e.g., `-d` for delete)
|
|
234
|
+
* **Arguments**: Positional and variadic parameters
|
|
235
|
+
* **Options**: Named parameters with type validation
|
|
236
|
+
* **Flags**: Boolean switches
|
|
237
|
+
* **Env vars**: Environment variables to set
|
|
238
|
+
|
|
239
|
+
// Options and Flags
|
|
240
|
+
== Options and Flags
|
|
241
|
+
|
|
242
|
+
Options and flags are defined in action definitions with rich metadata for type validation and formatting.
|
|
243
|
+
|
|
244
|
+
=== Options
|
|
245
|
+
|
|
246
|
+
Options are named parameters with values.
|
|
247
|
+
|
|
248
|
+
[source,yaml]
|
|
249
|
+
----
|
|
250
|
+
options:
|
|
251
|
+
- name: output
|
|
252
|
+
type: file
|
|
253
|
+
cli: --export-filename
|
|
254
|
+
description: Output filename
|
|
255
|
+
required: true
|
|
256
|
+
assignment_delimiter: equals
|
|
257
|
+
|
|
258
|
+
- name: format
|
|
259
|
+
type: symbol
|
|
260
|
+
cli: --export-type
|
|
261
|
+
values: [svg, png, pdf, eps]
|
|
262
|
+
description: Output format
|
|
263
|
+
----
|
|
264
|
+
|
|
265
|
+
=== Flags
|
|
266
|
+
|
|
267
|
+
Flags are boolean switches without values.
|
|
268
|
+
|
|
269
|
+
[source,yaml]
|
|
270
|
+
----
|
|
271
|
+
flags:
|
|
272
|
+
- name: verbose
|
|
273
|
+
cli: --verbose
|
|
274
|
+
description: Verbose output
|
|
275
|
+
default: false
|
|
276
|
+
assignment_delimiter: none
|
|
277
|
+
|
|
278
|
+
- name: quiet
|
|
279
|
+
cli: -q
|
|
280
|
+
description: Quiet mode
|
|
281
|
+
default: false
|
|
282
|
+
assignment_delimiter: none
|
|
283
|
+
----
|
|
284
|
+
|
|
285
|
+
=== Option Styles
|
|
286
|
+
|
|
287
|
+
Supported option styles across platforms:
|
|
288
|
+
|
|
289
|
+
[cols="2,1,2"]
|
|
290
|
+
|===
|
|
291
|
+
|Style |Example |Platforms
|
|
292
|
+
|
|
293
|
+
|double_dash_equals
|
|
294
|
+
|`--output=file.png`
|
|
295
|
+
|Unix-like
|
|
296
|
+
|
|
297
|
+
|double_dash_space
|
|
298
|
+
|`--output file.png`
|
|
299
|
+
|Unix-like
|
|
300
|
+
|
|
301
|
+
|single_dash_equals
|
|
302
|
+
|`-q=85`
|
|
303
|
+
|Unix-like
|
|
304
|
+
|
|
305
|
+
|single_dash_space
|
|
306
|
+
|`-q 85`
|
|
307
|
+
|Unix-like
|
|
308
|
+
|
|
309
|
+
|slash_colon
|
|
310
|
+
|`/format:pdf`
|
|
311
|
+
|Windows (cmd)
|
|
312
|
+
|
|
313
|
+
|slash_space
|
|
314
|
+
|`/format pdf`
|
|
315
|
+
|Windows (cmd)
|
|
316
|
+
|===
|
|
317
|
+
|
|
318
|
+
Use `assignment_delimiter: auto` to detect automatically from the `cli:` prefix.
|
|
319
|
+
|
|
320
|
+
// Shell
|
|
321
|
+
== Shell
|
|
322
|
+
|
|
323
|
+
Ukiryu supports multiple shells with proper command formatting and argument escaping.
|
|
324
|
+
|
|
325
|
+
=== Supported Shells
|
|
326
|
+
|
|
327
|
+
* **Unix-like**: `bash`, `zsh`, `fish`, `sh`
|
|
328
|
+
* **Windows**: `powershell`, `cmd`
|
|
329
|
+
* **Git Bash/MSYS**: `bash` on Windows
|
|
330
|
+
|
|
331
|
+
=== Shell Detection
|
|
332
|
+
|
|
333
|
+
[source,ruby]
|
|
334
|
+
----
|
|
335
|
+
# Automatic detection
|
|
336
|
+
shell = Ukiryu::Shell.detect # => :bash, :zsh, :powershell, etc.
|
|
337
|
+
|
|
338
|
+
# Platform-specific available shells
|
|
339
|
+
Ukiryu::Shell.valid_for_platform(:macos) # => [:bash, :zsh, :fish, :sh]
|
|
340
|
+
Ukiryu::Shell.valid_for_platform(:windows) # => [:powershell, :cmd]
|
|
341
|
+
|
|
342
|
+
# Check availability
|
|
343
|
+
Ukiryu::Shell.available?(:zsh) # => true/false
|
|
344
|
+
----
|
|
345
|
+
|
|
346
|
+
=== Shell-Specific Formatting
|
|
347
|
+
|
|
348
|
+
Each shell handles paths, escaping, and joining differently:
|
|
349
|
+
|
|
350
|
+
[source,ruby]
|
|
351
|
+
----
|
|
352
|
+
# Bash/Zsh/Fish - single quotes for literal strings
|
|
353
|
+
tool.execute(:convert, inputs: ['My File.svg'])
|
|
354
|
+
# => inkscape 'My File.svg' --export-filename=output.png
|
|
355
|
+
|
|
356
|
+
# PowerShell - different escaping
|
|
357
|
+
tool.execute(:convert, inputs: ['My File.svg'])
|
|
358
|
+
# => inkscape 'My File.svg' --export-filename=output.png
|
|
359
|
+
|
|
360
|
+
# cmd - double quotes for paths with spaces
|
|
361
|
+
tool.execute(:convert, inputs: ['My File.svg'])
|
|
362
|
+
# => inkscape "My File.svg" --export-filename=output.png
|
|
363
|
+
----
|
|
364
|
+
|
|
365
|
+
=== Explicit Shell Configuration
|
|
366
|
+
|
|
367
|
+
[source,ruby]
|
|
368
|
+
----
|
|
369
|
+
# Set shell explicitly
|
|
370
|
+
Ukiryu.configure do |config|
|
|
371
|
+
config.default_shell = :zsh
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
# Or per-tool
|
|
375
|
+
tool = Ukiryu::Tool.get(:inkscape, shell: :fish)
|
|
376
|
+
----
|
|
377
|
+
|
|
378
|
+
// Platform
|
|
379
|
+
== Platform
|
|
380
|
+
|
|
381
|
+
Ukiryu detects the operating system and adapts behavior accordingly.
|
|
382
|
+
|
|
383
|
+
=== Supported Platforms
|
|
384
|
+
|
|
385
|
+
* **`:macos`** - macOS systems
|
|
386
|
+
* **`:linux`** - Linux distributions
|
|
387
|
+
* **`:windows`** - Windows systems
|
|
388
|
+
|
|
389
|
+
=== Platform Detection
|
|
390
|
+
|
|
391
|
+
[source,ruby]
|
|
392
|
+
----
|
|
393
|
+
# Automatic detection
|
|
394
|
+
platform = Ukiryu::Platform.detect # => :macos, :linux, or :windows
|
|
395
|
+
|
|
396
|
+
# Platform checks
|
|
397
|
+
Ukiryu::Platform.macos? # => true/false
|
|
398
|
+
Ukiryu::Platform.linux? # => true/false
|
|
399
|
+
Ukiryu::Platform.windows? # => true/false
|
|
400
|
+
Ukiryu::Platform.unix? # => true for macOS or Linux
|
|
401
|
+
----
|
|
402
|
+
|
|
403
|
+
=== Platform-Specific Behavior
|
|
404
|
+
|
|
405
|
+
==== Search Paths
|
|
406
|
+
|
|
407
|
+
Each platform has different executable locations:
|
|
408
|
+
|
|
409
|
+
[source,yaml]
|
|
410
|
+
----
|
|
411
|
+
search_paths:
|
|
412
|
+
macos:
|
|
413
|
+
- '/Applications/Inkscape.app/Contents/MacOS/inkscape'
|
|
414
|
+
- '/opt/homebrew/bin/inkscape'
|
|
415
|
+
- '/usr/local/bin/inkscape'
|
|
416
|
+
linux:
|
|
417
|
+
- '/usr/bin/inkscape'
|
|
418
|
+
- '/usr/local/bin/inkscape'
|
|
419
|
+
windows:
|
|
420
|
+
- 'C:/Program Files/Inkscape/bin/inkscape.exe'
|
|
421
|
+
- 'C:/Program Files (x86)/Inkscape/bin/inkscape.exe'
|
|
422
|
+
----
|
|
423
|
+
|
|
424
|
+
==== Profile Selection
|
|
425
|
+
|
|
426
|
+
Tools select compatible profiles based on platform:
|
|
427
|
+
|
|
428
|
+
[source,yaml]
|
|
429
|
+
----
|
|
430
|
+
profiles:
|
|
431
|
+
- name: modern_unix
|
|
432
|
+
platforms: [macos, linux]
|
|
433
|
+
shells: [bash, zsh, fish, sh]
|
|
434
|
+
|
|
435
|
+
- name: windows_powershell
|
|
436
|
+
platforms: [windows]
|
|
437
|
+
shells: [powershell]
|
|
438
|
+
----
|
|
439
|
+
|
|
440
|
+
=== Explicit Platform Configuration
|
|
441
|
+
|
|
442
|
+
[source,ruby]
|
|
443
|
+
----
|
|
444
|
+
# Set platform explicitly
|
|
445
|
+
Ukiryu.configure do |config|
|
|
446
|
+
config.default_platform = :linux
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
# Or per-tool
|
|
450
|
+
tool = Ukiryu::Tool.get(:inkscape, platform: :macos)
|
|
451
|
+
----
|
|
452
|
+
|
|
453
|
+
// Type System
|
|
454
|
+
== Type System
|
|
455
|
+
|
|
456
|
+
Ukiryu validates parameters against defined types.
|
|
457
|
+
|
|
458
|
+
=== Supported Types
|
|
459
|
+
|
|
460
|
+
[cols="1,1,2"]
|
|
461
|
+
|===
|
|
462
|
+
|Type |Description |Example
|
|
463
|
+
|
|
464
|
+
|file
|
|
465
|
+
|File path with platform formatting
|
|
466
|
+
|`inputs: ['drawing.svg']`
|
|
467
|
+
|
|
468
|
+
|string
|
|
469
|
+
|Text string
|
|
470
|
+
|`text: 'hello world'`
|
|
471
|
+
|
|
472
|
+
|integer
|
|
473
|
+
|Whole number with range validation
|
|
474
|
+
|`dpi: 300`
|
|
475
|
+
|
|
476
|
+
|float
|
|
477
|
+
|Decimal number with range validation
|
|
478
|
+
|`opacity: 0.5`
|
|
479
|
+
|
|
480
|
+
|symbol
|
|
481
|
+
|Enumerated value from list
|
|
482
|
+
|`format: :png`
|
|
483
|
+
|
|
484
|
+
|boolean
|
|
485
|
+
|True/false flag
|
|
486
|
+
|`verbose: true`
|
|
487
|
+
|
|
488
|
+
|array
|
|
489
|
+
|Multiple values with separator
|
|
490
|
+
|`export_ids: ['id1', 'id2']`
|
|
491
|
+
|===
|
|
492
|
+
|
|
493
|
+
=== Type Validation
|
|
494
|
+
|
|
495
|
+
[source,ruby]
|
|
496
|
+
----
|
|
497
|
+
# Valid
|
|
498
|
+
tool.execute(:export, {
|
|
499
|
+
inputs: ['drawing.svg'], # Array of files
|
|
500
|
+
format: :png, # Symbol
|
|
501
|
+
dpi: 300 # Integer
|
|
502
|
+
})
|
|
503
|
+
|
|
504
|
+
# Invalid - raises error
|
|
505
|
+
tool.execute(:export, {
|
|
506
|
+
format: :unsupported, # Not in values list
|
|
507
|
+
dpi: -5 # Outside range
|
|
508
|
+
})
|
|
509
|
+
----
|
|
510
|
+
|
|
511
|
+
// Register Auto-Management
|
|
512
|
+
== Register Auto-Management
|
|
513
|
+
|
|
514
|
+
Ukiryu automatically manages the tool register for you.
|
|
515
|
+
|
|
516
|
+
=== Automatic Discovery
|
|
517
|
+
|
|
518
|
+
The register location is automatically discovered in this order:
|
|
519
|
+
|
|
520
|
+
1. **Environment Variable**: `UKIRYU_REGISTER` (highest priority)
|
|
521
|
+
2. **Auto-Clone**: `~/.ukiryu/register` (auto-cloned on first use)
|
|
522
|
+
|
|
523
|
+
=== Auto-Cloning
|
|
524
|
+
|
|
525
|
+
On first use, if no register is found, Ukiryu will:
|
|
526
|
+
|
|
527
|
+
1. Check if git is available
|
|
528
|
+
2. Clone from `https://github.com/ukiryu/register`
|
|
529
|
+
3. Store in `~/.ukiryu/register`
|
|
530
|
+
4. Validate the clone integrity
|
|
531
|
+
|
|
532
|
+
[source,bash]
|
|
533
|
+
----
|
|
534
|
+
# First run - auto-clone happens automatically
|
|
535
|
+
ukiryu list
|
|
536
|
+
# => Cloning register from https://github.com/ukiryu/register...done
|
|
537
|
+
# => Listing tools from ~/.ukiryu/register/tools/
|
|
538
|
+
----
|
|
539
|
+
|
|
540
|
+
=== Manual Register Management
|
|
541
|
+
|
|
542
|
+
[source,bash]
|
|
543
|
+
----
|
|
544
|
+
# Update register
|
|
545
|
+
ukiryu register update
|
|
546
|
+
|
|
547
|
+
# Re-clone register
|
|
548
|
+
ukiryu register reclone
|
|
549
|
+
|
|
550
|
+
# Show register info
|
|
551
|
+
ukiryu register info
|
|
552
|
+
----
|
|
553
|
+
|
|
554
|
+
=== Using a Custom Register
|
|
555
|
+
|
|
556
|
+
[source,bash]
|
|
557
|
+
----
|
|
558
|
+
# Set custom register location
|
|
559
|
+
export UKIRYU_REGISTER=/path/to/custom/register
|
|
560
|
+
ukiryu list
|
|
561
|
+
----
|
|
562
|
+
|
|
563
|
+
// Schema Validation
|
|
564
|
+
== Schema Validation
|
|
565
|
+
|
|
566
|
+
Tool definitions are validated against JSON Schema.
|
|
567
|
+
|
|
568
|
+
=== Schema Discovery
|
|
569
|
+
|
|
570
|
+
The schema is discovered in this order:
|
|
571
|
+
|
|
572
|
+
1. **Environment Variable**: `UKIRYU_SCHEMA_PATH`
|
|
573
|
+
2. **Remote URL**: `https://raw.githubusercontent.com/ukiryu/schemas/refs/heads/main/v1/tool.schema.yaml`
|
|
574
|
+
|
|
575
|
+
=== Using a Local Schema
|
|
576
|
+
|
|
577
|
+
[source,bash]
|
|
578
|
+
----
|
|
579
|
+
# Set custom schema location
|
|
580
|
+
export UKIRYU_SCHEMA_PATH=/path/to/custom/schema.yaml
|
|
581
|
+
ukiryu validate file tool.yaml
|
|
582
|
+
----
|
|
583
|
+
|
|
584
|
+
// Configuration Precedence
|
|
585
|
+
== Configuration Precedence
|
|
586
|
+
|
|
587
|
+
Ukiryu supports multiple configuration methods with clear precedence.
|
|
588
|
+
|
|
589
|
+
=== Configuration Layers
|
|
590
|
+
|
|
591
|
+
[cols="1,1,2"]
|
|
592
|
+
|===
|
|
593
|
+
|Method |Precedence |Use Case
|
|
594
|
+
|
|
595
|
+
|Environment Variables
|
|
596
|
+
|Highest
|
|
597
|
+
|CI/CD, deployment scripts
|
|
598
|
+
|
|
599
|
+
|CLI Parameters
|
|
600
|
+
|Medium
|
|
601
|
+
|Interactive use, one-off commands
|
|
602
|
+
|
|
603
|
+
|Ruby API
|
|
604
|
+
|Low
|
|
605
|
+
|Programmatic use, libraries
|
|
606
|
+
|
|
607
|
+
|Profile Defaults
|
|
608
|
+
|Lowest
|
|
609
|
+
|Tool-specific defaults
|
|
610
|
+
|===
|
|
611
|
+
|
|
612
|
+
=== Example: Setting Timeout
|
|
613
|
+
|
|
614
|
+
[source,ruby]
|
|
615
|
+
----
|
|
616
|
+
# Profile default: 90 seconds
|
|
617
|
+
# Ruby API parameter: 60 seconds
|
|
618
|
+
# CLI parameter: 120 seconds
|
|
619
|
+
# ENV variable: 180 seconds (wins!)
|
|
620
|
+
|
|
621
|
+
tool = Ukiryu::Tool.get(:inkscape)
|
|
622
|
+
result = tool.execute(:export, params, timeout: 60)
|
|
623
|
+
----
|
|
624
|
+
|
|
625
|
+
[source,bash]
|
|
626
|
+
----
|
|
627
|
+
# Environment variable always wins
|
|
628
|
+
export UKIRYU_TIMEOUT=180
|
|
629
|
+
ukiryu exec inkscape export timeout=120 inputs=drawing.svg
|
|
630
|
+
----
|
|
631
|
+
|
|
632
|
+
// Error Handling
|
|
633
|
+
== Error Handling
|
|
634
|
+
|
|
635
|
+
Ukiryu provides structured error information.
|
|
636
|
+
|
|
637
|
+
=== Error Types
|
|
638
|
+
|
|
639
|
+
* `ToolNotFoundError` - Tool not in register
|
|
640
|
+
* `ProfileNotFoundError` - No compatible profile for platform/shell
|
|
641
|
+
* `ExecutionError` - Command failed (non-zero exit)
|
|
642
|
+
* `TimeoutError` - Command exceeded timeout
|
|
643
|
+
|
|
644
|
+
=== Error Information
|
|
645
|
+
|
|
646
|
+
[source,ruby]
|
|
647
|
+
----
|
|
648
|
+
begin
|
|
649
|
+
result = tool.execute(:export, params)
|
|
650
|
+
rescue Ukiryu::ExecutionError => e
|
|
651
|
+
puts "Command failed!"
|
|
652
|
+
puts "Executable: #{e.result.command_info.executable}"
|
|
653
|
+
puts "Full command: #{e.result.command_info.full_command}"
|
|
654
|
+
puts "Exit status: #{e.result.output.exit_status}"
|
|
655
|
+
puts "Stderr: #{e.result.output.stderr}"
|
|
656
|
+
puts "Duration: #{e.result.metadata.duration_seconds}s"
|
|
657
|
+
end
|
|
658
|
+
----
|
|
659
|
+
|
|
660
|
+
// Next Steps
|
|
661
|
+
== Next Steps
|
|
662
|
+
|
|
663
|
+
* link:/interfaces/ruby-api[Ruby API] - Programming interface details
|
|
664
|
+
* link:/interfaces/cli[Command Line Interface] - CLI usage and options
|
|
665
|
+
* link:/understanding/architecture[Architecture] - Deep dive into internals
|
|
666
|
+
* link:/advanced/writing-profiles[Writing Profiles] - Create your own tool profiles
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Getting Started
|
|
4
|
+
nav_order: 2
|
|
5
|
+
has_children: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
= Getting Started
|
|
9
|
+
|
|
10
|
+
Welcome to Ukiryu! This section will help you install Ukiryu and get started with basic usage.
|
|
11
|
+
|
|
12
|
+
// Overview
|
|
13
|
+
== Overview
|
|
14
|
+
|
|
15
|
+
This section covers:
|
|
16
|
+
|
|
17
|
+
* link:/getting-started/installation[Installation] - How to install Ukiryu
|
|
18
|
+
* link:/getting-started/quick-start[Quick Start] - Basic usage examples
|
|
19
|
+
* link:/getting-started/core-concepts[Core Concepts] - Understanding Ukiryu's architecture
|
|
20
|
+
|
|
21
|
+
// Prerequisites
|
|
22
|
+
== Prerequisites
|
|
23
|
+
|
|
24
|
+
* Ruby 2.7 or higher
|
|
25
|
+
* Basic familiarity with command-line tools
|
|
26
|
+
* (Optional) Access to tools like ImageMagick, Inkscape, Ghostscript, etc.
|
|
27
|
+
|
|
28
|
+
// What You'll Learn
|
|
29
|
+
== What You'll Learn
|
|
30
|
+
|
|
31
|
+
After completing this section, you will be able to:
|
|
32
|
+
|
|
33
|
+
* Install and configure Ukiryu
|
|
34
|
+
* Execute basic tool commands
|
|
35
|
+
* Understand how Ukiryu adapts to different platforms
|
|
36
|
+
* Use the Ruby API and CLI effectively
|