lux-hammer 0.2.7 → 0.2.8
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/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: 8e861fb5cdf9bbcc0533942927d96f35348fbb50614c1dd50b16279f1d81d2d3
|
|
4
|
+
data.tar.gz: 1a31f522be7d9c75847ce820169da0c5b9a4418522c224d3d284ce004ecbcd2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a1d7af3b3523903b10bf5a1b0af1d4d1c340b8a1a6736d6b9b0884f0cc0adca7eaa46079dfb24274147043c4e79b9a8ea497afcb7b6c80389ec73c4ee302d28f
|
|
7
|
+
data.tar.gz: e436739c8da3cb6dcfbd64135405930e70ba07eab53a5f1c880d3240319ce9c77118d61ba6fb766ef5817dfa54b0fa37fe17d1167236b4221afc156e04f3463f
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.8
|
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
|