clawthor 0.3.0
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 +7 -0
- data/LICENSE +21 -0
- data/README.md +365 -0
- data/exe/clawthor +8 -0
- data/lib/clawthor/cli.rb +140 -0
- data/lib/clawthor/compiler.rb +1258 -0
- data/lib/clawthor/dsl.rb +95 -0
- data/lib/clawthor/orchestrator.rb +35 -0
- data/lib/clawthor/primitives/agent.rb +77 -0
- data/lib/clawthor/primitives/command.rb +20 -0
- data/lib/clawthor/primitives/hook.rb +50 -0
- data/lib/clawthor/primitives/module.rb +75 -0
- data/lib/clawthor/primitives/service.rb +80 -0
- data/lib/clawthor/primitives/skill.rb +135 -0
- data/lib/clawthor/primitives/task.rb +60 -0
- data/lib/clawthor/primitives/workspace.rb +71 -0
- data/lib/clawthor/registry.rb +38 -0
- data/lib/clawthor/version.rb +5 -0
- data/lib/clawthor.rb +38 -0
- metadata +92 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6985fc3b3cab8dd71f374358ff84a42372eb2f2d21e6cd8e85977d46872b45e4
|
|
4
|
+
data.tar.gz: 89406b5bf06098b8ab948e420f68e0be3348869bd789b2ad97dea5e09b242d5f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e346098784576ed8394bfca1a835242d3872daa79fa5341173c58b90f4070794460e04debd7f6c240b2d7990162fd212736277e9830a639cfc079d8f88d46048
|
|
7
|
+
data.tar.gz: d00b4ac51010bbe2a7caa93cb4728b12cc84aa2879eb774a4bc65d0a1c05f3206eb8136f63a9b40af3f0121bb49dae05e0f8da87e505cb9890bdc6c65f9c267d
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Anthropic
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
# Clawthor Gem
|
|
2
|
+
|
|
3
|
+
The **compiler** that transforms declarative plugin definitions into fully-functional Claude Code plugins.
|
|
4
|
+
|
|
5
|
+
## What This Does
|
|
6
|
+
|
|
7
|
+
You write a simple Ruby file describing your plugin (skills, commands, agents). Clawthor compiles it into:
|
|
8
|
+
- Plugin manifest (JSON)
|
|
9
|
+
- Markdown documentation
|
|
10
|
+
- YAML configuration files
|
|
11
|
+
- Ready to use!
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
### Option 1: From RubyGems (recommended)
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
gem install clawthor
|
|
19
|
+
clawthor --version
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Option 2: Build locally
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
git clone <repo>
|
|
26
|
+
cd clawthor
|
|
27
|
+
gem build clawthor.gemspec
|
|
28
|
+
gem install ./clawthor-*.gem
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 5-Minute Example
|
|
32
|
+
|
|
33
|
+
### 1. Create a definition file
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
# my_plugin.rb
|
|
37
|
+
workspace :my_plugin do
|
|
38
|
+
author "Your Name"
|
|
39
|
+
version "1.0.0"
|
|
40
|
+
|
|
41
|
+
skill :code_review do
|
|
42
|
+
description "Code review guidelines"
|
|
43
|
+
section "Python" do
|
|
44
|
+
guideline "Check for type hints"
|
|
45
|
+
guideline "Verify docstrings"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
command :review do
|
|
50
|
+
description "Review Python code"
|
|
51
|
+
template do
|
|
52
|
+
prompt "Review the following code with Python guidelines"
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 2. Compile it
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
clawthor compile my_plugin.rb output/
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 3. Use it
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
claude --plugin-dir ./output
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Done! You now have a working Claude Code plugin.
|
|
71
|
+
|
|
72
|
+
## CLI Usage
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Compile with defaults
|
|
76
|
+
clawthor compile
|
|
77
|
+
|
|
78
|
+
# Specify files
|
|
79
|
+
clawthor compile definition.rb output/
|
|
80
|
+
|
|
81
|
+
# Marketplace format (for distribution)
|
|
82
|
+
clawthor compile definition.rb output/ --marketplace
|
|
83
|
+
|
|
84
|
+
# Get help
|
|
85
|
+
clawthor compile --help
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Programmatic Usage
|
|
89
|
+
|
|
90
|
+
```ruby
|
|
91
|
+
require "clawthor"
|
|
92
|
+
|
|
93
|
+
# Compile a plugin
|
|
94
|
+
Clawthor.compile(
|
|
95
|
+
definition_file: "my_plugin.rb",
|
|
96
|
+
output_dir: "dist/",
|
|
97
|
+
mode: :plugin # :plugin or :marketplace
|
|
98
|
+
)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## DSL Basics
|
|
102
|
+
|
|
103
|
+
### The Six Primitives
|
|
104
|
+
|
|
105
|
+
```ruby
|
|
106
|
+
workspace :my_plugin do
|
|
107
|
+
# Metadata
|
|
108
|
+
author "Your Name"
|
|
109
|
+
version "1.0.0"
|
|
110
|
+
|
|
111
|
+
# 1. Skill — A knowledge area with sections and guidelines
|
|
112
|
+
skill :best_practices do
|
|
113
|
+
description "Development best practices"
|
|
114
|
+
section "Testing" do
|
|
115
|
+
guideline "Write tests first"
|
|
116
|
+
guideline "Aim for 80%+ coverage"
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# 2. Command — A user-runnable slash command
|
|
121
|
+
command :review do
|
|
122
|
+
description "Review code"
|
|
123
|
+
template do
|
|
124
|
+
prompt "Review this code"
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# 3. Agent — A specialized role
|
|
129
|
+
agent :reviewer do
|
|
130
|
+
description "Code reviewer"
|
|
131
|
+
contract "Review code thoroughly"
|
|
132
|
+
instruction "Be constructive"
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# 4. Task — Persistent working memory
|
|
136
|
+
task :planning do
|
|
137
|
+
description "Project plan"
|
|
138
|
+
template "# Project Plan\n\n## Goals\n"
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# 5. Hook — Lifecycle interceptor (advanced)
|
|
142
|
+
hook :on_start do
|
|
143
|
+
description "Initialize plugin"
|
|
144
|
+
handler "initialize_plugin()"
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# 6. Service — Background process (advanced)
|
|
148
|
+
service :health_check do
|
|
149
|
+
description "Monitor plugin health"
|
|
150
|
+
command "health-check.sh"
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Modules (Reusable Blocks)
|
|
156
|
+
|
|
157
|
+
Define reusable modules and include them in multiple plugins:
|
|
158
|
+
|
|
159
|
+
```ruby
|
|
160
|
+
# Define a module
|
|
161
|
+
define_module :testing_module do
|
|
162
|
+
skill :testing do
|
|
163
|
+
description "Testing best practices"
|
|
164
|
+
section "Pytest" do
|
|
165
|
+
guideline "Use fixtures for setup"
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
command :test do
|
|
170
|
+
description "Run tests"
|
|
171
|
+
template { prompt "Run the tests" }
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# Use in your plugin
|
|
176
|
+
workspace :my_plugin do
|
|
177
|
+
version "1.0.0"
|
|
178
|
+
use :testing_module # Includes all definitions from module
|
|
179
|
+
|
|
180
|
+
# Add your own definitions
|
|
181
|
+
skill :custom do
|
|
182
|
+
description "My custom skill"
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Common Patterns
|
|
188
|
+
|
|
189
|
+
### Organize Skills by Topic
|
|
190
|
+
|
|
191
|
+
```ruby
|
|
192
|
+
skill :python do
|
|
193
|
+
description "Python development"
|
|
194
|
+
|
|
195
|
+
section "Type Hints" do
|
|
196
|
+
guideline "Use type hints on all functions"
|
|
197
|
+
guideline "Check with mypy"
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
section "Testing" do
|
|
201
|
+
guideline "Write pytest tests"
|
|
202
|
+
guideline "Cover edge cases"
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Create Actionable Commands
|
|
208
|
+
|
|
209
|
+
```ruby
|
|
210
|
+
command :refactor do
|
|
211
|
+
description "Refactor Python code"
|
|
212
|
+
template do
|
|
213
|
+
prompt "Refactor this code to be more Pythonic"
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
command :test do
|
|
218
|
+
description "Run test suite"
|
|
219
|
+
template do
|
|
220
|
+
prompt "Run: pytest tests/"
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Build Custom Agents
|
|
226
|
+
|
|
227
|
+
```ruby
|
|
228
|
+
agent :code_reviewer do
|
|
229
|
+
description "Expert code reviewer"
|
|
230
|
+
|
|
231
|
+
contract "Review code against best practices"
|
|
232
|
+
instruction "Identify improvements"
|
|
233
|
+
instruction "Explain reasoning"
|
|
234
|
+
instruction "Be constructive and helpful"
|
|
235
|
+
end
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Real Example: Baseline Plugin
|
|
239
|
+
|
|
240
|
+
See [../baseline/](../baseline/) for a production-ready plugin with:
|
|
241
|
+
- 5 reusable modules
|
|
242
|
+
- Multiple skills and agents
|
|
243
|
+
- Real commands and tasks
|
|
244
|
+
- Full documentation
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
cd ../baseline
|
|
248
|
+
rake build # Compile
|
|
249
|
+
claude --plugin-dir ./output # Use it
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Testing Your Plugin
|
|
253
|
+
|
|
254
|
+
### Validate the manifest
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
clawthor compile my_plugin.rb output/
|
|
258
|
+
claude plugin validate output/
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Test with Claude Code
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
claude --plugin-dir ./output
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Then try your commands in a session.
|
|
268
|
+
|
|
269
|
+
## Development
|
|
270
|
+
|
|
271
|
+
### Run tests
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
rake test # All tests (unit + integration)
|
|
275
|
+
rake test_fast # Unit tests only (~1 sec)
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Build locally
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
gem build clawthor.gemspec
|
|
282
|
+
gem install ./clawthor-*.gem
|
|
283
|
+
clawthor --version
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Debug compilation
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# Verbose output
|
|
290
|
+
clawthor compile my_plugin.rb output/ --debug
|
|
291
|
+
|
|
292
|
+
# Check generated files
|
|
293
|
+
ls -la output/
|
|
294
|
+
cat output/plugin.json | jq
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Troubleshooting
|
|
298
|
+
|
|
299
|
+
### "No such file or directory" error
|
|
300
|
+
|
|
301
|
+
Make sure your definition file exists and the path is correct:
|
|
302
|
+
```bash
|
|
303
|
+
ls my_plugin.rb
|
|
304
|
+
clawthor compile my_plugin.rb output/
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Plugin doesn't appear in Claude Code
|
|
308
|
+
|
|
309
|
+
1. Validate: `claude plugin validate output/`
|
|
310
|
+
2. Check the path: `claude --plugin-dir ./output`
|
|
311
|
+
3. Restart Claude Code
|
|
312
|
+
|
|
313
|
+
### Ruby version issues
|
|
314
|
+
|
|
315
|
+
Clawthor requires Ruby 3.0+:
|
|
316
|
+
```bash
|
|
317
|
+
ruby --version
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
## Advanced
|
|
321
|
+
|
|
322
|
+
### Two Output Modes
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
# Standard plugin layout
|
|
326
|
+
clawthor compile my_plugin.rb output/
|
|
327
|
+
|
|
328
|
+
# Marketplace layout (for distribution)
|
|
329
|
+
clawthor compile my_plugin.rb dist/ --marketplace
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
The marketplace format includes additional files for publishing.
|
|
333
|
+
|
|
334
|
+
### Custom Modules
|
|
335
|
+
|
|
336
|
+
Create `.rb` files with module definitions and require them:
|
|
337
|
+
|
|
338
|
+
```ruby
|
|
339
|
+
require_relative './my_module'
|
|
340
|
+
|
|
341
|
+
workspace :my_plugin do
|
|
342
|
+
use :my_module
|
|
343
|
+
end
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## Migration from Older Systems
|
|
347
|
+
|
|
348
|
+
Using `ruby generate.rb` or an old Clawthor version? See [MIGRATION.md](MIGRATION.md).
|
|
349
|
+
|
|
350
|
+
## Resources
|
|
351
|
+
|
|
352
|
+
- [Baseline Plugin](../baseline/README.md) — Production-ready reference
|
|
353
|
+
- [CHANGELOG](CHANGELOG.md) — Version history
|
|
354
|
+
- [MIGRATION](MIGRATION.md) — Upgrading guide
|
|
355
|
+
|
|
356
|
+
## License
|
|
357
|
+
|
|
358
|
+
MIT License
|
|
359
|
+
|
|
360
|
+
## Next Steps
|
|
361
|
+
|
|
362
|
+
1. [Write your first plugin](#5-minute-example)
|
|
363
|
+
2. [Explore the baseline plugin](../baseline/README.md)
|
|
364
|
+
3. [Copy modules to reuse](../baseline/modules/)
|
|
365
|
+
4. [Run tests](#run-tests)
|
data/exe/clawthor
ADDED
data/lib/clawthor/cli.rb
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "fileutils"
|
|
4
|
+
|
|
5
|
+
module Clawthor
|
|
6
|
+
class CLI
|
|
7
|
+
def self.start(argv)
|
|
8
|
+
cli = new
|
|
9
|
+
cli.run(argv)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def run(argv)
|
|
13
|
+
# Parse arguments
|
|
14
|
+
args = argv.dup
|
|
15
|
+
|
|
16
|
+
# Remove 'compile' subcommand if present
|
|
17
|
+
args.shift if args[0] == "compile"
|
|
18
|
+
|
|
19
|
+
mode = args.delete("--marketplace") ? :marketplace : :plugin
|
|
20
|
+
|
|
21
|
+
# Handle help
|
|
22
|
+
if args.any? { |arg| arg.start_with?("--") && arg != "--marketplace" }
|
|
23
|
+
help_arg = args.find { |arg| arg.start_with?("--") }
|
|
24
|
+
if %w[--help -h].include?(help_arg)
|
|
25
|
+
puts usage
|
|
26
|
+
return 0
|
|
27
|
+
end
|
|
28
|
+
if %w[--version -v].include?(help_arg)
|
|
29
|
+
puts "clawthor #{Clawthor::VERSION}"
|
|
30
|
+
return 0
|
|
31
|
+
end
|
|
32
|
+
puts "Error: Unknown option(s): #{args.select { |arg| arg.start_with?("--") }.join(', ')}"
|
|
33
|
+
puts usage
|
|
34
|
+
return 2
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Validate argument count
|
|
38
|
+
if args.length > 2
|
|
39
|
+
puts "Error: Too many positional arguments."
|
|
40
|
+
puts usage
|
|
41
|
+
return 1
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Get definition and output paths
|
|
45
|
+
definition_file = args[0] || File.join(Dir.pwd, "definition.rb")
|
|
46
|
+
output_dir = args[1] || File.join(Dir.pwd, "output")
|
|
47
|
+
|
|
48
|
+
# Validate definition file exists
|
|
49
|
+
unless File.exist?(definition_file)
|
|
50
|
+
puts "Error: Definition file not found: #{definition_file}"
|
|
51
|
+
puts usage
|
|
52
|
+
return 1
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Print header
|
|
56
|
+
puts "╔══════════════════════════════════════════════╗"
|
|
57
|
+
puts "║ Claude Code Orchestration DSL Compiler ║"
|
|
58
|
+
puts "╚══════════════════════════════════════════════╝"
|
|
59
|
+
puts ""
|
|
60
|
+
puts "Definition: #{definition_file}"
|
|
61
|
+
puts "Output: #{output_dir}"
|
|
62
|
+
puts "Mode: #{mode}"
|
|
63
|
+
puts ""
|
|
64
|
+
|
|
65
|
+
# Compile
|
|
66
|
+
registry = compile(definition_file, output_dir, mode)
|
|
67
|
+
|
|
68
|
+
# Print summary
|
|
69
|
+
puts ""
|
|
70
|
+
if mode == :marketplace
|
|
71
|
+
plugin_name = registry.workspace ? registry.workspace.plugin_name : "orchestrator"
|
|
72
|
+
plugin_dir = File.join(output_dir, "plugins", plugin_name)
|
|
73
|
+
marketplace_manifest = File.join(output_dir, ".claude-plugin", "marketplace.json")
|
|
74
|
+
puts "To validate:"
|
|
75
|
+
puts " claude plugin validate #{marketplace_manifest}"
|
|
76
|
+
puts " claude plugin validate #{plugin_dir}"
|
|
77
|
+
else
|
|
78
|
+
puts "To test:"
|
|
79
|
+
puts " claude --plugin-dir #{output_dir}"
|
|
80
|
+
puts ""
|
|
81
|
+
puts "To install into a project:"
|
|
82
|
+
plugin_name = registry.workspace ? registry.workspace.plugin_name : "orchestrator"
|
|
83
|
+
puts " cp -r #{output_dir}/ .claude-plugins/#{plugin_name}/"
|
|
84
|
+
end
|
|
85
|
+
puts ""
|
|
86
|
+
puts "Commands available (namespaced):"
|
|
87
|
+
registry.commands.each do |name, _cmd|
|
|
88
|
+
ns = registry.workspace ? registry.workspace.plugin_name : "orchestrator"
|
|
89
|
+
puts " /#{ns}:#{name.to_s.tr('_', '-')}"
|
|
90
|
+
end
|
|
91
|
+
puts ""
|
|
92
|
+
|
|
93
|
+
0
|
|
94
|
+
rescue => e
|
|
95
|
+
puts "Error: #{e.message}"
|
|
96
|
+
puts e.backtrace.join("\n") if ENV["DEBUG"]
|
|
97
|
+
1
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
private
|
|
101
|
+
|
|
102
|
+
def compile(definition_file, output_dir, mode)
|
|
103
|
+
# Reset registry for fresh compilation
|
|
104
|
+
registry = Clawthor::DSL::Registry.new
|
|
105
|
+
Clawthor::DSL.send(:remove_const, :REGISTRY) if Clawthor::DSL.const_defined?(:REGISTRY)
|
|
106
|
+
Clawthor::DSL.const_set(:REGISTRY, registry)
|
|
107
|
+
|
|
108
|
+
# Evaluate the definition file in DSL context
|
|
109
|
+
context = Object.new
|
|
110
|
+
context.extend(Clawthor::DSL::Methods)
|
|
111
|
+
context.instance_eval(File.read(definition_file), definition_file)
|
|
112
|
+
|
|
113
|
+
# Compile to output
|
|
114
|
+
compiler = Clawthor::Compiler.new(Clawthor::DSL::REGISTRY, output_dir, mode: mode)
|
|
115
|
+
compiler.compile!
|
|
116
|
+
|
|
117
|
+
Clawthor::DSL::REGISTRY
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def usage
|
|
121
|
+
<<~USAGE
|
|
122
|
+
Usage: clawthor compile [OPTIONS] [DEFINITION] [OUTPUT]
|
|
123
|
+
|
|
124
|
+
OPTIONS:
|
|
125
|
+
--marketplace Generate marketplace layout
|
|
126
|
+
--help, -h Show help
|
|
127
|
+
--version, -v Show version
|
|
128
|
+
|
|
129
|
+
ARGUMENTS:
|
|
130
|
+
DEFINITION Path to definition file (default: ./definition.rb)
|
|
131
|
+
OUTPUT Output directory (default: ./output)
|
|
132
|
+
|
|
133
|
+
EXAMPLES:
|
|
134
|
+
clawthor compile
|
|
135
|
+
clawthor compile definition.rb output/
|
|
136
|
+
clawthor compile definition.rb output/ --marketplace
|
|
137
|
+
USAGE
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|