cmdparse 3.0.0 → 3.0.1

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
  SHA1:
3
- metadata.gz: e414fd7955af00e870b2561d5c25a52021bfdede
4
- data.tar.gz: 67959e99ad88ce48ec6d7169d0fa71f4c57af3d6
3
+ metadata.gz: 33a196cd6254f66b778a929a732504effd20e170
4
+ data.tar.gz: 07691ec8406bdaaa936fb3e7572cafe1e8ec4234
5
5
  SHA512:
6
- metadata.gz: b920d98ca7204ac027cd6746f03dcf5432afcdcc8f2aa75207c3f93a736833348bc5e5d3ca1ce21e6345fb5bac66ad8c2d0022618c7cadbf428196ba526ea820
7
- data.tar.gz: 839020aed5e17ce55773564d8b6c75dcbba44c251ee775f006eaf132689cd48a375f1acd13a74b5c5d6fb099cb2ed33153fe36be98fdf5672b82ac814c9b92d5
6
+ metadata.gz: cc1ced1a1fea8c62eaa11761d78c172bdb0769291fe27637a4ae5199bea8294a0cb78c71d7610012cc7ec36338a3625fed99d9bd5dfea13526342235f2b8170f
7
+ data.tar.gz: 6f494cb30fb84875aaa584a360332e0fbd2c2cb3009afd4913ee8e22c7ea69d30396c86490ec505daadd97c430910c54aaaa50d3832cb40151dd46cc4a4b089e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.0
1
+ 3.0.1
@@ -24,7 +24,7 @@
24
24
 
25
25
  <!-- Sidebar -->
26
26
  <div id="sidebar">
27
- <h1 id="logo"><a href="{relocatable: /}">cmdparse</a><br /><span>v 3.0.0</span></h1>
27
+ <h1 id="logo"><a href="{relocatable: /}">cmdparse</a><br /><span>v 3.0.1</span></h1>
28
28
 
29
29
  <!-- Nav -->
30
30
  <nav id="nav">
@@ -57,5 +57,18 @@
57
57
 
58
58
  </div>
59
59
 
60
+ <!-- Start of StatCounter Code for Default Guide -->
61
+ <script type="text/javascript">
62
+ var sc_project=10338773;
63
+ var sc_invisible=1;
64
+ var sc_security="7779f3af";
65
+ </script>
66
+ <script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script>
67
+ <noscript><div class="statcounter">
68
+ <a title="free hit counters" href="http://statcounter.com/" class="statcounter">
69
+ <img class="statcounter" src="http://c.statcounter.com/10338773/0/7779f3af/1/" alt="free hit counters" />
70
+ </a>
71
+ </div></noscript>
72
+ <!-- End of StatCounter Code for Default Guide -->
60
73
  </body>
61
74
  </html>
@@ -5,6 +5,15 @@ sort_info: 8
5
5
  ---
6
6
  ## News
7
7
 
8
+ ### 2015-03-14 cmdparse 3.0.1 released!
9
+
10
+ Changes:
11
+
12
+ * Commands in usage line are now shown sorted
13
+ * Long lines with embedded new lines are now correctly formatted
14
+ * The built-in version command can now be told to not add the `-v` and `--version` switches
15
+
16
+
8
17
  ### 2015-03-12 cmdparse 3.0.0 released!
9
18
 
10
19
  This version is not compatible with previous versions of cmdparse and requires at least Ruby 2.0.
@@ -0,0 +1,5 @@
1
+ ---
2
+ entries:
3
+ alcn: /**/*.html
4
+ default_change_freq: monthly
5
+ ---
@@ -18,7 +18,7 @@ OptionParser::Officious.delete('help')
18
18
  module CmdParse
19
19
 
20
20
  # The version of this cmdparse implemention
21
- VERSION = '3.0.0'
21
+ VERSION = '3.0.1'
22
22
 
23
23
 
24
24
  # Base class for all cmdparse errors.
@@ -486,7 +486,7 @@ module CmdParse
486
486
  #
487
487
  # {command | other_command | another_command }
488
488
  def usage_commands
489
- (commands.size > 0 ? "{#{commands.keys.join(" | ")}}" : '')
489
+ (commands.size > 0 ? "{#{commands.keys.sort.join(" | ")}}" : '')
490
490
  end
491
491
 
492
492
  # Returns the formatted short description.
@@ -519,7 +519,7 @@ module CmdParse
519
519
  end.join('')
520
520
  end
521
521
  cond_format_help_section("Available commands", describe_commands.call(self),
522
- condition: takes_commands?)
522
+ condition: takes_commands?, preformatted: true)
523
523
  end
524
524
 
525
525
  # Returns the formatted arguments of this command.
@@ -542,7 +542,7 @@ module CmdParse
542
542
  summary << format(line, width: command_parser.help_line_width - command_parser.help_indent,
543
543
  indent: summary_width + 1, indent_first_line: false) << "\n"
544
544
  end
545
- cond_format_help_section(title, summary, condition: !summary.empty?)
545
+ cond_format_help_section(title, summary, condition: !summary.empty?, preformatted: true)
546
546
  end
547
547
 
548
548
  # This hook method is called when the command (or one of its super-commands) is added to another
@@ -571,11 +571,26 @@ module CmdParse
571
571
  #
572
572
  # Summary:
573
573
  # help - Provide help for individual commands
574
- def cond_format_help_section(title, *lines, condition: true, indent: true)
574
+ #
575
+ # Options:
576
+ #
577
+ # condition:: The formatted help section is only returned if the condition is +true+.
578
+ #
579
+ # indent:: Whether the lines should be indented with CommandParser#help_indent spaces.
580
+ #
581
+ # preformatted:: Assume that the given lines are already correctly formatted and don't try to
582
+ # reformat them.
583
+ def cond_format_help_section(title, *lines, condition: true, indent: true, preformatted: false)
575
584
  if condition
576
- "#{title}:\n" << format(lines.flatten.join("\n"),
577
- indent: (indent ? command_parser.help_indent : 0),
578
- indent_first_line: true) << "\n\n"
585
+ out = "#{title}:\n"
586
+ lines = lines.flatten.join("\n").split(/\n/)
587
+ if preformatted
588
+ lines.map! {|l| ' '*command_parser.help_indent << l} if indent
589
+ out << lines.join("\n")
590
+ else
591
+ out << format(lines.join("\n"), indent: (indent ? command_parser.help_indent : 0), indent_first_line: true)
592
+ end
593
+ out << "\n\n"
579
594
  else
580
595
  ''
581
596
  end
@@ -596,8 +611,8 @@ module CmdParse
596
611
  indent: command_parser.help_indent, indent_first_line: false)
597
612
  content = (content || '').dup
598
613
  line_length = width - indent
599
- first_line_pattern = other_lines_pattern = /\A.{1,#{line_length}}\z|\A.{1,#{line_length}}[ \n]/
600
- (first_line_pattern = /\A.{1,#{width}}\z|\A.{1,#{width}}[ \n]/) unless indent_first_line
614
+ first_line_pattern = other_lines_pattern = /\A.{1,#{line_length}}\z|\A.{1,#{line_length}}[ \n]/m
615
+ (first_line_pattern = /\A.{1,#{width}}\z|\A.{1,#{width}}[ \n]/m) unless indent_first_line
601
616
  pattern = first_line_pattern
602
617
 
603
618
  content.split(/\n\n/).map do |paragraph|
@@ -673,7 +688,8 @@ module CmdParse
673
688
 
674
689
  # The default version command.
675
690
  #
676
- # It adds the options "-v" and "--version" to the CommandParser#global_options.
691
+ # It adds the options "-v" and "--version" to the CommandParser#main_options but this can be
692
+ # changed in ::new.
677
693
  #
678
694
  # When the command is specified on the command line (or one of the above mentioned options), it
679
695
  # shows the version of the program configured by the settings
@@ -682,15 +698,22 @@ module CmdParse
682
698
  # * command_parser.main_options.version
683
699
  class VersionCommand < Command
684
700
 
685
- def initialize #:nodoc:
701
+ # Create a new version command.
702
+ #
703
+ # Options:
704
+ #
705
+ # add_switches:: Specifies whether the '-v' and '--version' switches should be added to the
706
+ # CommandParser#main_options
707
+ def initialize(add_switches: true)
686
708
  super('version', takes_commands: false)
687
709
  short_desc("Show the version of the program")
710
+ @add_switches = add_switches
688
711
  end
689
712
 
690
713
  def on_after_add #:nodoc:
691
714
  command_parser.main_options.on_tail("--version", "-v", "Show the version of the program") do
692
715
  execute
693
- end
716
+ end if @add_switches
694
717
  end
695
718
 
696
719
  def execute #:nodoc:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmdparse
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Leitner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-12 00:00:00.000000000 Z
11
+ date: 2015-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webgen
@@ -46,6 +46,7 @@ files:
46
46
  - doc/installation.page
47
47
  - doc/metainfo
48
48
  - doc/news.page
49
+ - doc/sitemap.sitemap
49
50
  - doc/tutorial.page
50
51
  - doc/virtual
51
52
  - example/net.rb
@@ -75,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
76
  version: '0'
76
77
  requirements: []
77
78
  rubyforge_project:
78
- rubygems_version: 2.4.5
79
+ rubygems_version: 2.2.2
79
80
  signing_key:
80
81
  specification_version: 4
81
82
  summary: Advanced command line parser supporting commands