command_mapper-gen 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c241ca5b66548980b82622d0f6d2afed8c8fe1cd5972f9ea50194caf997285e7
4
- data.tar.gz: cce7267f71f4e7b0e74a22c075cc4b3985e0a4318dd087ea3afc17459c5fbb6e
3
+ metadata.gz: 7db506d5c89f29a11905cde640c4ffcd3e785e87c480b38a771a747eca744909
4
+ data.tar.gz: 9845fd793e8056ed3975735db5728b6909b5ccfd9b64c4547bcbad1957e2d998
5
5
  SHA512:
6
- metadata.gz: d3e63e2fbd4a0f8932f9e01d9badce388f1d579ed50473b3367c1000ac1b25566797c74f73011fe5f2d9b52298ca5f249eb5a1c6f89202e55aef8d6b946dd584
7
- data.tar.gz: edf6134a36e69963291c2838905ab57948b34e79f2dc67f715b4463e74f4968548364380e7cb682c1a21c74dca3aaed3bec5bbe9b42ed00dfc285cc1a51c58c9
6
+ metadata.gz: afe9ffc7ae1e7e85a3de3219d3400c861a3b392f2441e0036c5c25ded432988c030965fa93f6be6d81debd7da2d0c1063da4307ac27a3951a61006a9538c375b
7
+ data.tar.gz: 9a234d24838b9486af96d2db48185fd88a2106dd0b412a947c11d08fe854dc9ea53824a01706f989fd2dc9d42373a6c3c0a3f715f0a50cb15f3231dd0943edbe
data/.yardopts CHANGED
@@ -1 +1 @@
1
- --markup markdown --title "CommandMapper::Gen Documentation" --protected --quiet
1
+ --markup markdown --title "CommandMapper::Gen Documentation" --protected
data/ChangeLog.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 0.1.1 / 2025-06-24
2
+
3
+ * Improvements and bug fixes for `--help` parsing logic:
4
+ * Ignore explicit option flags when parsing the `usage:` line.
5
+ * Tweak the option parser for Go-style `--help` output.
6
+
1
7
  ### 0.1.0 / 2021-11-25
2
8
 
3
9
  * Initial release:
data/Gemfile CHANGED
@@ -10,6 +10,7 @@ group :development do
10
10
  gem 'simplecov', '~> 0.20', require: false
11
11
 
12
12
  gem 'kramdown'
13
+ gem 'redcarpet', platform: :mri
13
14
  gem 'yard', '~> 0.9'
14
15
  gem 'yard-spellcheck'
15
16
 
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2021 Hal Brodigan
1
+ Copyright (c) 2021-2025 Hal Brodigan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -137,7 +137,7 @@ end
137
137
 
138
138
  ## License
139
139
 
140
- Copyright (c) 2021 Hal Brodigan
140
+ Copyright (c) 2021-2025 Hal Brodigan
141
141
 
142
142
  See {file:LICENSE.txt} for license information.
143
143
 
@@ -198,7 +198,7 @@ module CommandMapper
198
198
  #
199
199
  def print_parser_error(command,string,error)
200
200
  $stderr.puts "Failed to parse line in `#{command.command_string} --help`:"
201
- $stderr.puts ""
201
+ $stderr.puts
202
202
  $stderr.puts " #{string}"
203
203
  $stderr.puts
204
204
 
@@ -210,7 +210,7 @@ module CommandMapper
210
210
  $stderr.puts error.message
211
211
  end
212
212
 
213
- $stderr.puts ""
213
+ $stderr.puts
214
214
  end
215
215
 
216
216
  #
@@ -117,6 +117,9 @@ module CommandMapper
117
117
  @command_name.split(/[_-]+/).map(&:capitalize).join
118
118
  end
119
119
 
120
+ # URL to the documentation for `CommandMapper::Command`.
121
+ COMMAND_DOC_URL = "https://rubydoc.info/gems/command_mapper/CommandMapper/Command"
122
+
120
123
  #
121
124
  # Converts the parsed command to Ruby source code.
122
125
  #
@@ -132,6 +135,8 @@ module CommandMapper
132
135
  lines << "#"
133
136
  lines << "# Represents the `#{@command_name}` command"
134
137
  lines << "#"
138
+ lines << "# @see #{COMMAND_DOC_URL}"
139
+ lines << "#"
135
140
 
136
141
  lines << "class #{class_name} < CommandMapper::Command"
137
142
  lines << ""
@@ -108,9 +108,12 @@ module CommandMapper
108
108
  #
109
109
  # Parses an individual argument node.
110
110
  #
111
- # @param [Hash] node
111
+ # @param [Hash] argument
112
112
  # An argument node.
113
113
  #
114
+ # @param [Hash{Symbol => Object}] kwargs
115
+ # Additional keyword arguments for {Command#argument}.
116
+ #
114
117
  def parse_argument(argument,**kwargs)
115
118
  name = argument[:name].to_s.downcase
116
119
  keywords = kwargs
@@ -141,7 +144,7 @@ module CommandMapper
141
144
  keywords[:required] = false
142
145
 
143
146
  parse_arguments(node[:optional], **keywords)
144
- else
147
+ elsif node[:argument]
145
148
  parse_argument(node[:argument], **keywords)
146
149
  end
147
150
  end
@@ -58,13 +58,23 @@ module CommandMapper
58
58
 
59
59
  rule(:square_brackets) do
60
60
  (
61
- str('[') >> space? >>
62
- value >>
63
- space? >> str(']')
61
+ str('[') >> space? >> value >> space? >> str(']')
64
62
  ).as(:optional)
65
63
  end
66
64
 
65
+ rule(:single_quotes) do
66
+ str("'") >> name >> str("'")
67
+ end
68
+
69
+ rule(:double_quotes) do
70
+ str('"') >> name >> str('"')
71
+ end
72
+
67
73
  rule(:value_container) do
74
+ # "'...'"
75
+ single_quotes |
76
+ # "\"...\""
77
+ double_quotes |
68
78
  # "{...}"
69
79
  curly_braces |
70
80
  # "<...>"
@@ -115,7 +125,7 @@ module CommandMapper
115
125
  rule(:option_summary) { any.repeat(1) }
116
126
 
117
127
  rule(:option_line) do
118
- (str("\t") | spaces) >> option >> str(',').maybe >>
128
+ (str("\t") | spaces) >> option >> match[',:'].maybe >>
119
129
  (match[' \t'].repeat(1) >> option_summary).maybe >> any.absent?
120
130
  end
121
131
 
@@ -1,6 +1,6 @@
1
1
  module CommandMapper
2
2
  module Gen
3
3
  # Version of command_mapper-gen
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
6
6
  end
data/spec/cli_spec.rb CHANGED
@@ -58,6 +58,8 @@ describe CommandMapper::Gen::CLI do
58
58
  "#",
59
59
  "# Represents the `#{command_name}` command",
60
60
  "#",
61
+ "# @see #{CommandMapper::Gen::Command::COMMAND_DOC_URL}",
62
+ "#",
61
63
  "class #{command_name.capitalize} < CommandMapper::Command",
62
64
  "",
63
65
  " command \"#{command_name}\" do",
data/spec/command_spec.rb CHANGED
@@ -146,6 +146,8 @@ describe CommandMapper::Gen::Command do
146
146
  "#",
147
147
  "# Represents the `#{subject.command_name}` command",
148
148
  "#",
149
+ "# @see #{described_class::COMMAND_DOC_URL}",
150
+ "#",
149
151
  "class #{subject.class_name} < CommandMapper::Command",
150
152
  "",
151
153
  " command #{subject.command_name.inspect} do",
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: command_mapper-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2021-11-26 00:00:00.000000000 Z
10
+ date: 2025-06-25 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: parslet
@@ -111,7 +110,6 @@ metadata:
111
110
  bug_tracker_uri: https://github.com/postmodern/command_mapper-gen.rb/issues
112
111
  changelog_uri: https://github.com/postmodern/command_mapper-gen.rb/blob/master/ChangeLog.md
113
112
  rubygems_mfa_required: 'true'
114
- post_install_message:
115
113
  rdoc_options: []
116
114
  require_paths:
117
115
  - lib
@@ -126,8 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
124
  - !ruby/object:Gem::Version
127
125
  version: '0'
128
126
  requirements: []
129
- rubygems_version: 3.2.22
130
- signing_key:
127
+ rubygems_version: 3.6.2
131
128
  specification_version: 4
132
129
  summary: Generates command_mapper Ruby classes for a given command
133
130
  test_files: []