benry-cmdapp 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd749bd655750efee168dacda0d1f2609548a31fff1dd2c9d53e323c0fad145b
4
- data.tar.gz: a3484ad1a239396af73c7173ac7272ac156d2e424b2a4d90f732cd1e1196bf95
3
+ metadata.gz: 55cda8dcd81c8ebb9de51a568d94408fc177d6f9425e25bba54b2b3cf6836762
4
+ data.tar.gz: c5d12034ccedd2fe0c18916a566588f21e58267d7e0d20d42c807d5f3134fbc1
5
5
  SHA512:
6
- metadata.gz: 8ede7e8ca3b150642c064343ec3a310164986595a313e97a9e96cb7766fa6b5725102f482a40edfcfa3edafdea681cf58459d8845fa4b0622716e709dfe07024
7
- data.tar.gz: 87a6c333685eb856704c37c62692a177384dae41475a55402904cd4d3c24d1dcfde8211e8df5d7718ec981e5a452b61f1d02894f7ed47671e13b71fb930f3a20
6
+ metadata.gz: d4991a36655d4ab69e709a83e8e5965c00c704d91fb9323a79db33c29d47fb08f2787add47270d42e12180cc8dbdd0a80bfe840c6624105e63fe209e09ca0f1c
7
+ data.tar.gz: d9b9a8b181fbcf9741aa4685b23a0efcf3ddf507c2363a63a8eab1d96b35f8f60e64a980834c47b37eedef71a404b28e00d4e93aa956a10b09b3f5b5e809e2ba
data/CHANGES.md CHANGED
@@ -2,6 +2,13 @@ CHANGES
2
2
  =======
3
3
 
4
4
 
5
+ Release 1.1.2 (2024-09-30)
6
+ --------------------------
7
+
8
+ * [change] Change to report error when prefix not matched any task names.
9
+ * [bugfix] Fix a minor bug related to listing candidates.
10
+
11
+
5
12
  Release 1.1.1 (2023-12-29)
6
13
  --------------------------
7
14
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Benry-CmdApp
2
2
 
3
- ($Release: 1.1.1 $)
3
+ ($Release: 1.1.2 $)
4
4
 
5
5
 
6
6
  ## What's This?
data/benry-cmdapp.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "benry-cmdapp"
5
- spec.version = "$Release: 1.1.1 $".split()[1]
5
+ spec.version = "$Release: 1.1.2 $".split()[1]
6
6
  spec.author = "kwatch"
7
7
  spec.email = "kwatch@gmail.com"
8
8
  spec.platform = Gem::Platform::RUBY
@@ -21,7 +21,7 @@
21
21
  <ul class="nav">
22
22
  </ul>
23
23
  </nav>
24
- <p>($Release: 1.1.1 $)</p>
24
+ <p>($Release: 1.1.2 $)</p>
25
25
  <section class="section" id="whats-this">
26
26
  <h2>What's This?</h2>
27
27
  <p>Benry-CmdApp is a framework to create command-line application.
data/lib/benry/cmdapp.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  ###
5
- ### $Release: 1.1.1 $
5
+ ### $Release: 1.1.2 $
6
6
  ### $Copyright: copyright(c) 2023 kwatch@gmail.com $
7
7
  ### $License: MIT License $
8
8
  ###
@@ -1491,12 +1491,12 @@ module Benry::CmdApp
1491
1491
  #; [!nwwrd] if prefix is 'xxx:' and alias name is 'xxx' and action name of alias matches to 'xxx:', skip it because it will be shown in 'Aliases:' section.
1492
1492
  _category_action?(metadata, prefix)
1493
1493
  }
1494
- #s1 = str.empty? ? nil : render_section(header(:HEADER_ACTIONS), str)
1495
- s1 = render_section(header(:HEADER_ACTIONS), str)
1494
+ s1 = str.empty? ? nil : render_section(header(:HEADER_ACTIONS), str)
1496
1495
  #; [!otvbt] includes name of alias which corresponds to action starting with prefix.
1496
+ #; [!bgpsm] includes name of alias which is equal to prefix name excluding tailing ':'.
1497
1497
  #; [!h5ek7] includes hidden aliases when `all: true` passed.
1498
1498
  str = _render_metadata_list(c.format_action, all: all) {|metadata|
1499
- metadata.alias? && metadata.action.start_with?(prefix)
1499
+ metadata.alias? && (metadata.action.start_with?(prefix) || metadata.action == prefix2)
1500
1500
  }
1501
1501
  #; [!9lnn2] alias names in candidate list are sorted by action name.
1502
1502
  str = str.each_line.sort_by {|line|
@@ -1505,9 +1505,12 @@ module Benry::CmdApp
1505
1505
  }.join()
1506
1506
  #; [!80t51] alias names are displayed in separated section from actions.
1507
1507
  s2 = str.empty? ? nil : render_section(header(:HEADER_ALIASES), str)
1508
- #; [!rqx7w] returns header string if both no actions nor aliases found with names starting with prefix.
1508
+ #; [!jek9k] raises error when no actions nor aliases found starting with prefix.
1509
+ arr = [s1, s2].compact()
1510
+ ! arr.empty? or
1511
+ raise CommandError, "'#{prefix}' : Unknown prefix. (Hint: try ':' instead of '#{prefix}' to list all prefixes.)"
1509
1512
  #; [!3c3f1] returns list of actions which name starts with prefix specified.
1510
- return [s1, s2].compact().join("\n")
1513
+ return arr.join("\n")
1511
1514
  end
1512
1515
 
1513
1516
  def _category_action?(md, prefix)
data/test/help_test.rb CHANGED
@@ -728,6 +728,30 @@ END
728
728
  END
729
729
  end
730
730
 
731
+ spec "[!bgpsm] includes name of alias which is equal to prefix name excluding tailing ':'." do
732
+ HelpTestAction.class_eval do
733
+ category "p5983:", action: "aaa" do
734
+ @action.("AAA")
735
+ def aaa()
736
+ end
737
+ @action.("BBB")
738
+ def bbb()
739
+ end
740
+ end
741
+ end
742
+ Benry::CmdApp.define_alias("p59", ["p5983", "-h"]) # !!!!
743
+ x = @builder.section_candidates("p5983:")
744
+ ok {x} == <<"END"
745
+ \e[1;34mActions:\e[0m
746
+ p5983 : AAA
747
+ \e[2m (alias: p59 (with '-h'))\e[0m
748
+ p5983:bbb : BBB
749
+
750
+ \e[1;34mAliases:\e[0m
751
+ p59 : alias for 'p5983 -h'
752
+ END
753
+ end
754
+
731
755
  spec "[!h5ek7] includes hidden aliases when `all: true` passed." do
732
756
  Benry::CmdApp.define_alias("add", "git:stage", hidden: true)
733
757
  at_end { Benry::CmdApp.undef_alias("add") }
@@ -798,9 +822,11 @@ END
798
822
  ok {x} =~ /^\e\[1;34mAliases:\e\[0m$/
799
823
  end
800
824
 
801
- spec "[!rqx7w] returns header string if both no actions nor aliases found with names starting with prefix." do
802
- x = @builder.section_candidates("blabla:")
803
- ok {x} == "\e[1;34mActions:\e[0m\n\n"
825
+ spec "[!jek9k] raises error when no actions nor aliases found starting with prefix." do
826
+ pr = proc { @builder.section_candidates("blabla:") }
827
+ ok {pr}.raise?(Benry::CmdApp::CommandError,
828
+ "'blabla:' : Unknown prefix."\
829
+ " (Hint: try ':' instead of 'blabla:' to list all prefixes.)")
804
830
  end
805
831
 
806
832
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benry-cmdapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kwatch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-29 00:00:00.000000000 Z
11
+ date: 2024-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benry-cmdopt
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  requirements: []
98
- rubygems_version: 3.4.10
98
+ rubygems_version: 3.4.19
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: Command-line application framework