lib/aws_ec2/command.rb in aws-ec2-0.9.0 vs lib/aws_ec2/command.rb in aws-ec2-1.0.0
- old
+ new
@@ -16,23 +16,52 @@
module AwsEc2
class Command < Thor
class << self
def dispatch(m, args, options, config)
# Allow calling for help via:
- # aws_ec2 command help
- # aws_ec2 command -h
- # aws_ec2 command --help
- # aws_ec2 command -D
+ # aws-ec2 command help
+ # aws-ec2 command -h
+ # aws-ec2 command --help
+ # aws-ec2 command -D
#
# as well thor's normal way:
#
- # aws_ec2 help command
+ # aws-ec2 help command
help_flags = Thor::HELP_MAPPINGS + ["help"]
if args.length > 1 && !(args & help_flags).empty?
args -= help_flags
args.insert(-2, "help")
end
+
+ # aws-ec2 version
+ # aws-ec2 --version
+ # aws-ec2 -v
+ version_flags = ["--version", "-v"]
+ if args.length == 1 && !(args & version_flags).empty?
+ args = ["version"]
+ end
+
super
end
+
+ # Override command_help to include the description at the top of the
+ # long_description.
+ def command_help(shell, command_name)
+ meth = normalize_command_name(command_name)
+ command = all_commands[meth]
+ alter_command_description(command)
+ super
+ end
+
+ def alter_command_description(command)
+ return unless command
+ long_desc = if command.long_description
+ "#{command.description}\n\n#{command.long_description}"
+ else
+ command.description
+ end
+ command.long_description = long_desc
+ end
+ private :alter_command_description
end
end
end