lux-hammer 0.2.7 → 0.2.9
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/bin/hammer +17 -0
- data/lib/lux-hammer.rb +22 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c947550570c131a847f744a29edc640efd04f969648bfc79926092f125a88559
|
|
4
|
+
data.tar.gz: 672a2a5fbf302fae7853ca72dc0fb7bca4e42a0723201c45fba57845b8c0b541
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 85e701c6c4ce14be709878d1ba055c5dc53d02f6d5ea41bdc1afe50f36444ce0964852c158ff315e7a085c3adebfcca7b336782b7feb6c7999f19d3e2f0aa52d
|
|
7
|
+
data.tar.gz: 20e83b75b2578870ceb1c06cb7f917601f524d236943eb906abc59340fe531c5f654897ff5d4b829f3cc176269f7dfe10791551e5bdff4a4726b0e1459fb90d7
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.9
|
data/bin/hammer
CHANGED
|
@@ -6,5 +6,22 @@ local_lib = File.expand_path('../lib/lux-hammer.rb', __dir__)
|
|
|
6
6
|
if File.file?(local_lib)
|
|
7
7
|
$LOAD_PATH.unshift File.dirname(local_lib)
|
|
8
8
|
end
|
|
9
|
+
|
|
10
|
+
# Auto-activate Bundler when invoked inside a Bundler-managed project so
|
|
11
|
+
# Hammerfile + lib/tasks/*_hammer.rb get framework code (e.g. lux-fw's
|
|
12
|
+
# Dir.require_all, Hash#to_lux_hash) without users needing `bundle exec`.
|
|
13
|
+
# Bundler.require loads default-group gems (matches Rails-style boot).
|
|
14
|
+
# No-op (rescued) when Bundler isn't available or no Gemfile present.
|
|
15
|
+
if File.exist?('Gemfile') && !defined?(Bundler)
|
|
16
|
+
begin
|
|
17
|
+
require 'bundler/setup'
|
|
18
|
+
require 'bundler'
|
|
19
|
+
Bundler.require(:default)
|
|
20
|
+
rescue LoadError, StandardError
|
|
21
|
+
# bundler missing or Gemfile unusable - run without activation
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
9
25
|
require 'lux-hammer'
|
|
10
26
|
Hammer.cli(ARGV)
|
|
27
|
+
|
data/lib/lux-hammer.rb
CHANGED
|
@@ -388,6 +388,20 @@ class Hammer
|
|
|
388
388
|
pair&.last
|
|
389
389
|
end
|
|
390
390
|
|
|
391
|
+
# Returns the command at the parent that shares its name with this
|
|
392
|
+
# namespace. E.g. for path "gem:version" returns the `version` command
|
|
393
|
+
# in the `gem` namespace (if defined), so `gem:version:` listings can
|
|
394
|
+
# include `gem:version` itself at the top.
|
|
395
|
+
def find_namespace_sibling(canonical)
|
|
396
|
+
parts = canonical.to_s.split(':')
|
|
397
|
+
return nil if parts.empty?
|
|
398
|
+
parent = self
|
|
399
|
+
parts[0..-2].each do |seg|
|
|
400
|
+
parent = parent.namespaces[seg] or return nil
|
|
401
|
+
end
|
|
402
|
+
parent.commands[parts.last]
|
|
403
|
+
end
|
|
404
|
+
|
|
391
405
|
# Walk "ns1:ns2:cmd" -> [command, owning_class, canonical_path].
|
|
392
406
|
# Returns [nil, nil, nil] if any segment is missing or the final
|
|
393
407
|
# segment isn't a command. canonical_path uses the canonical name
|
|
@@ -581,11 +595,15 @@ class Hammer
|
|
|
581
595
|
|
|
582
596
|
def print_namespace_help(prefix, ns, full: false)
|
|
583
597
|
Shell.say "Usage: #{program_name} #{prefix}:COMMAND [ARGS]", :cyan
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
598
|
+
rows = []
|
|
599
|
+
sibling = find_namespace_sibling(prefix)
|
|
600
|
+
rows << [prefix, sibling] if sibling && !sibling.desc.empty?
|
|
601
|
+
ns.each_command(prefix) { |path, c| rows << [path, c] unless c.desc.empty? }
|
|
602
|
+
unless rows.empty?
|
|
587
603
|
Shell.say ''
|
|
588
|
-
|
|
604
|
+
Shell.say 'Commands:', :yellow
|
|
605
|
+
width = rows.map { |path, _| path.length }.max
|
|
606
|
+
emit_rows(rows.sort_by { |path, _| [path.count(':'), path] }, width)
|
|
589
607
|
end
|
|
590
608
|
print_global_flags
|
|
591
609
|
print_footer
|