lux-hammer 0.3.26 → 0.3.27
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/.version +1 -1
- data/AGENTS.md +7 -3
- data/README.md +13 -1
- data/lib/hammer/builtins.rb +32 -2
- data/lib/lux-hammer.rb +14 -0
- 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: cbcb0355f0ce770acb1ace879a1567ee1193de1da5ac6e6c32e36faa8f2a48fe
|
|
4
|
+
data.tar.gz: 8299d3bf2a47844e0e5c01ba73225d43be8aef718ceee3cf9603d0ec85e3e582
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6f5a7f793308a5f55e1bdb99ab85ae7aa8b271c92a073f33e1e7130f757395a97071da89a0933958cd89279a7a2004372a71746f1d83c945747ea1cb785f9f75
|
|
7
|
+
data.tar.gz: b5ee6d077d5b14fd5c448a28ea53e15da59198c067a568bee97193b5352cfea78dd073dff9054af58501453a72cbdae5b0d6c6af5e3e578004b102434a98b29d
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.27
|
data/AGENTS.md
CHANGED
|
@@ -22,8 +22,9 @@ usable as a library (`require 'lux-hammer'`, subclass `Hammer`, call
|
|
|
22
22
|
monkey-patches.
|
|
23
23
|
* **Zero runtime dependencies**. The gem must work with stdlib only. New
|
|
24
24
|
dependencies require explicit user approval.
|
|
25
|
-
* **Ruby >= 2.7
|
|
26
|
-
without flagging.
|
|
25
|
+
* **Ruby >= 2.7** for `lib/` and `bin/`. Do not use language features
|
|
26
|
+
introduced after 2.7 there without flagging. Bundled recipes may sit
|
|
27
|
+
higher - the `llm` recipe needs >= 3.1 (endless methods, shorthand hash).
|
|
27
28
|
* **`desc` is single-arg, multi-line allowed**. The argument is one
|
|
28
29
|
string; it may contain newlines. The first line is the brief shown in
|
|
29
30
|
command listings, the full string renders (indented) in per-command
|
|
@@ -300,7 +301,10 @@ Task contracts:
|
|
|
300
301
|
`--path NAME`, `--edit NAME`, `--run NAME [ARGS]` (use `--` to
|
|
301
302
|
forward flags through). Bare invocation lists.
|
|
302
303
|
* `h:init` - writes `Hammer::STARTER_HAMMERFILE` to `./Hammerfile`;
|
|
303
|
-
refuses if one exists.
|
|
304
|
+
refuses if one exists. `--script` writes `Hammer::STARTER_SCRIPT`
|
|
305
|
+
(shebang + one `hello` task) to stdout instead, or to a positional
|
|
306
|
+
TARGET with mode 0755. Both templates are single-quoted heredocs in
|
|
307
|
+
`lib/lux-hammer.rb` - the one source of truth, also rendered in help.
|
|
304
308
|
* `h:json` - `puts JSON` of `root.export_spec` (tasks grouped exactly
|
|
305
309
|
like the bare listing via `section_for`, root group keyed `__root`).
|
|
306
310
|
`--all` keeps the `h:` tree, `--compact` minifies.
|
data/README.md
CHANGED
|
@@ -634,6 +634,9 @@ Under the `h:` namespace:
|
|
|
634
634
|
* `h:version` - print the lux-hammer version.
|
|
635
635
|
* `h:recipes` - list / install / show / edit recipes.
|
|
636
636
|
* `h:init` - write a starter Hammerfile in cwd (refuses if one exists).
|
|
637
|
+
`--script` prints a minimal standalone CLI to stdout instead (shebang
|
|
638
|
+
plus one `hello` task) - pipe it to a file and `chmod +x`, or name a
|
|
639
|
+
target to write and chmod in one step.
|
|
637
640
|
* `h:json` - dump the CLI definition as JSON (tasks grouped like the
|
|
638
641
|
bare listing, with desc/options/examples/aliases/needs/cron); `--all`
|
|
639
642
|
includes the `h:` tasks, `--compact` minifies. Output is plain stdout
|
|
@@ -1135,7 +1138,16 @@ end
|
|
|
1135
1138
|
### `#!/usr/bin/env hammer` (single-file scripts)
|
|
1136
1139
|
|
|
1137
1140
|
For a one-off CLI that lives as a single executable file, point the
|
|
1138
|
-
shebang straight at `hammer` - no `require`, no boilerplate
|
|
1141
|
+
shebang straight at `hammer` - no `require`, no boilerplate. Start from
|
|
1142
|
+
the bundled template:
|
|
1143
|
+
|
|
1144
|
+
```sh
|
|
1145
|
+
$ hammer h:init --script greet # or: h:init --script > greet
|
|
1146
|
+
$ ./greet hello
|
|
1147
|
+
Hello from Hammer
|
|
1148
|
+
```
|
|
1149
|
+
|
|
1150
|
+
Then fill it in - the body is plain Hammerfile DSL:
|
|
1139
1151
|
|
|
1140
1152
|
```ruby
|
|
1141
1153
|
#!/usr/bin/env hammer
|
data/lib/hammer/builtins.rb
CHANGED
|
@@ -108,8 +108,24 @@ class Hammer
|
|
|
108
108
|
def register_init(klass)
|
|
109
109
|
klass.class_eval do
|
|
110
110
|
task :init do
|
|
111
|
-
desc
|
|
112
|
-
|
|
111
|
+
desc <<~TXT
|
|
112
|
+
Write a starter Hammerfile in the current directory.
|
|
113
|
+
|
|
114
|
+
--script prints a minimal standalone CLI (shebang + one `hello`
|
|
115
|
+
task) to stdout instead - pipe it to a file, chmod +x, run it.
|
|
116
|
+
Name a TARGET to write and chmod in one step.
|
|
117
|
+
TXT
|
|
118
|
+
example 'h:init'
|
|
119
|
+
example 'h:init --script > mytool && chmod +x mytool'
|
|
120
|
+
example 'h:init --script mytool'
|
|
121
|
+
opt :script, type: :boolean, alias: :s, desc: 'print a standalone executable CLI (TARGET writes + chmod +x)'
|
|
122
|
+
proc do |opts|
|
|
123
|
+
if opts[:script]
|
|
124
|
+
Hammer::Builtins.write_starter_script(opts[:args].first)
|
|
125
|
+
else
|
|
126
|
+
Hammer::Builtins.write_starter_hammerfile
|
|
127
|
+
end
|
|
128
|
+
end
|
|
113
129
|
end
|
|
114
130
|
end
|
|
115
131
|
end
|
|
@@ -237,6 +253,20 @@ class Hammer
|
|
|
237
253
|
Shell.say "created #{target}", :green
|
|
238
254
|
end
|
|
239
255
|
|
|
256
|
+
# `h:init --script`. No target -> stdout, so `> tool` works; with a
|
|
257
|
+
# target it lands executable. Never clobbers, same as the Hammerfile.
|
|
258
|
+
def write_starter_script(target = nil)
|
|
259
|
+
return puts(Hammer::STARTER_SCRIPT) unless target
|
|
260
|
+
|
|
261
|
+
if File.exist?(target)
|
|
262
|
+
Shell.print_error "#{target} already exists"
|
|
263
|
+
exit 1
|
|
264
|
+
end
|
|
265
|
+
File.write(target, Hammer::STARTER_SCRIPT)
|
|
266
|
+
File.chmod(0o755, target)
|
|
267
|
+
Shell.say "created #{target} (chmod +x)", :green
|
|
268
|
+
end
|
|
269
|
+
|
|
240
270
|
# Implementations of the `recipes` task's action flags, plus the
|
|
241
271
|
# no-flag listing view. Separate module so the task definition above
|
|
242
272
|
# stays small.
|
data/lib/lux-hammer.rb
CHANGED
|
@@ -1118,6 +1118,20 @@ class Hammer
|
|
|
1118
1118
|
end
|
|
1119
1119
|
RUBY
|
|
1120
1120
|
|
|
1121
|
+
# Minimal standalone CLI, dumped by `hammer h:init --script`. The
|
|
1122
|
+
# shebang is what `shebang_script` sniffs for, so `chmod +x` is all
|
|
1123
|
+
# that stands between this and a working binary.
|
|
1124
|
+
STARTER_SCRIPT ||= <<~'RUBY'
|
|
1125
|
+
#!/usr/bin/env hammer
|
|
1126
|
+
|
|
1127
|
+
desc 'My standalone CLI'
|
|
1128
|
+
|
|
1129
|
+
task :hello do
|
|
1130
|
+
desc 'Print a greeting'
|
|
1131
|
+
proc { say.green 'Hello from Hammer' }
|
|
1132
|
+
end
|
|
1133
|
+
RUBY
|
|
1134
|
+
|
|
1121
1135
|
# Default install dir used by install.sh and `hammer h:update`.
|
|
1122
1136
|
SELF_UPDATE_DIR ||= File.expand_path('~/.local/share/lux-hammer')
|
|
1123
1137
|
SELF_UPDATE_REPO ||= 'https://github.com/dux/hammer.git'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lux-hammer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.27
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dino Reic
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-08
|
|
11
|
+
date: 2026-09-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|