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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/bin/hammer +17 -0
  4. data/lib/lux-hammer.rb +22 -4
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5fc940f903d901587d17cd94c6f34eed5f92de64ded400a882228e34037cad1
4
- data.tar.gz: 480bd5d42e755ea6c92d956e48eb146777718e6be46a74042b9c8f0192479c27
3
+ metadata.gz: c947550570c131a847f744a29edc640efd04f969648bfc79926092f125a88559
4
+ data.tar.gz: 672a2a5fbf302fae7853ca72dc0fb7bca4e42a0723201c45fba57845b8c0b541
5
5
  SHA512:
6
- metadata.gz: 33bf95c45d0eba2bf3d37aa55f7dcb6dcf317c25b3badeaba965f00f582c27cb92285db07f360e290c3c8d41f82f575bbb6171583bd5cce106b065843f7ad08d
7
- data.tar.gz: 2dec31a7d86c8a3f525fa2beac4134576a634141001550b9226eed0ed723f6768a56bf404be4fbdf239a954eccb094be060695838a7c25cd820aae72af7db186
6
+ metadata.gz: 85e701c6c4ce14be709878d1ba055c5dc53d02f6d5ea41bdc1afe50f36444ce0964852c158ff315e7a085c3adebfcca7b336782b7feb6c7999f19d3e2f0aa52d
7
+ data.tar.gz: 20e83b75b2578870ceb1c06cb7f917601f524d236943eb906abc59340fe531c5f654897ff5d4b829f3cc176269f7dfe10791551e5bdff4a4726b0e1459fb90d7
data/.version CHANGED
@@ -1 +1 @@
1
- 0.2.7
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
- if full
585
- ns.each_command(prefix) { |path, c| print_full_block(path, c) unless c.desc.empty? }
586
- else
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
- print_command_list(ns, prefix)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lux-hammer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dino Reic