commander-openflighthpc 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 +4 -4
- data/lib/commander/command.rb +4 -6
- data/lib/commander/patches/validate_inputs.rb +4 -1
- data/lib/commander/runner.rb +25 -8
- data/lib/commander/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a40df29e6a019c3ff4bac1776e2752ceefd52ac7cf79f5e6d5d99ec32266c59b
|
4
|
+
data.tar.gz: 0fb111ee4776fd2fbcb359781e740f30572b7b0f6fb9474ddc014b11aa6c8da9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27a69ae0244b52ddd67288b77a54cda2b0e54bc115c2212960fed7761d7aefe75fc86fb83114b328283c136aab097ae8cfa28f8be061d68891ed1900b87ff4d9
|
7
|
+
data.tar.gz: 87a25ff68ff7c522989e4c67002b6903433af6ace6a12779d23855f1be4e7d2b5257f33bd452ac708a439344f83c51ba911014b117dac90f01bfd144c8bd8714
|
data/lib/commander/command.rb
CHANGED
@@ -9,6 +9,8 @@ OptionParser.prepend Commander::Patches::ImplicitShortTags
|
|
9
9
|
OptionParser.prepend Commander::Patches::DecimalInteger
|
10
10
|
|
11
11
|
module Commander
|
12
|
+
class SubCommandGroupError < StandardError; end
|
13
|
+
|
12
14
|
class Command
|
13
15
|
prepend Patches::ValidateInputs
|
14
16
|
|
@@ -159,7 +161,7 @@ module Commander
|
|
159
161
|
alias action when_called
|
160
162
|
|
161
163
|
##
|
162
|
-
# Handles displaying subcommand help. By default it will set the action to
|
164
|
+
# Handles displaying subcommand help. By default it will set the action to
|
163
165
|
# display the subcommand if the action hasn't already been set
|
164
166
|
|
165
167
|
def sub_command_group?
|
@@ -168,11 +170,7 @@ module Commander
|
|
168
170
|
|
169
171
|
def sub_command_group=(value)
|
170
172
|
@sub_command_group = value
|
171
|
-
if
|
172
|
-
self.action {
|
173
|
-
exec("#{$0} #{ARGV.join(" ")} --help")
|
174
|
-
}
|
175
|
-
end
|
173
|
+
self.action { raise SubCommandGroupError } if value
|
176
174
|
end
|
177
175
|
|
178
176
|
def configure_sub_command(runner)
|
@@ -27,7 +27,10 @@ module Commander
|
|
27
27
|
|
28
28
|
def assert_correct_number_of_args!(args)
|
29
29
|
return if primary_command_word == 'help'
|
30
|
-
|
30
|
+
too_many = too_many_args?(args)
|
31
|
+
if too_many && sub_command_group?
|
32
|
+
raise CommandUsageError, "unrecognised command. Please select from the following:"
|
33
|
+
elsif too_many
|
31
34
|
raise CommandUsageError, "excess arguments for command '#{primary_command_word}'"
|
32
35
|
elsif too_few_args?(args)
|
33
36
|
raise CommandUsageError, "insufficient arguments for command '#{primary_command_word}'"
|
data/lib/commander/runner.rb
CHANGED
@@ -3,20 +3,37 @@ require 'paint'
|
|
3
3
|
module Commander
|
4
4
|
class Runner
|
5
5
|
DEFAULT_ERROR_HANDLER = lambda do |runner, e|
|
6
|
-
|
6
|
+
error_msg = "#{Paint[runner.program(:name), '#2794d8']}: #{Paint[e.to_s, :red, :bright]}"
|
7
7
|
case e
|
8
8
|
when OptionParser::InvalidOption,
|
9
9
|
Commander::Runner::InvalidCommandError,
|
10
10
|
Commander::Patches::CommandUsageError
|
11
|
-
|
12
|
-
|
13
|
-
if
|
14
|
-
|
15
|
-
|
16
|
-
runner.command(
|
11
|
+
# Display the error message for a specific command. Most likely due to
|
12
|
+
# invalid command syntax
|
13
|
+
if cmd = runner.active_command
|
14
|
+
$stderr.puts error_msg
|
15
|
+
$stderr.puts "\nUsage:\n\n"
|
16
|
+
runner.command('help').run(cmd.name)
|
17
|
+
# Display the main app help text when called without `--help`
|
18
|
+
elsif runner.args_without_command_name.empty?
|
19
|
+
$stderr.puts "Usage:\n\n"
|
20
|
+
runner.command('help').run(:error)
|
21
|
+
# Display the main app help text when called with arguments. Mostly
|
22
|
+
# likely an invalid syntax error
|
17
23
|
else
|
18
|
-
|
24
|
+
$stderr.puts error_msg
|
25
|
+
$stderr.puts "\nUsage:\n\n"
|
26
|
+
runner.command('help').run(:error)
|
19
27
|
end
|
28
|
+
# Display the help text for sub command groups when called without `--help`
|
29
|
+
when SubCommandGroupError
|
30
|
+
if cmd = runner.active_command
|
31
|
+
$stderr.puts "Usage:\n\n"
|
32
|
+
runner.command('help').run(cmd.name)
|
33
|
+
end
|
34
|
+
# Catch all error message for all other issues
|
35
|
+
else
|
36
|
+
$stderr.puts error_msg
|
20
37
|
end
|
21
38
|
exit(1)
|
22
39
|
end
|
data/lib/commander/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commander-openflighthpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alces Flight Ltd
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-09-
|
13
|
+
date: 2019-09-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: highline
|