...
 
Commits (10)
inherit_from: .rubocop_todo.yml
AllCops:
TargetRubyVersion: 1.9
# not Ruby 1.9.3 compatible
Style/PercentLiteralDelimiters:
Enabled: false
# Offense count: 5
Encoding:
Enabled: false
......@@ -23,10 +30,10 @@ Style/NumericLiteralPrefix:
Style/MethodMissing:
Enabled: false
Style/SpaceInsideStringInterpolation:
Layout/SpaceInsideStringInterpolation:
Enabled: false
Style/MultilineOperationIndentation:
Layout/MultilineOperationIndentation:
Enabled: false
Style/EmptyMethod:
......
......@@ -6,7 +6,7 @@
# versions of RuboCop, may require this file to be generated again.
# Offense count: 2
Lint/Eval:
Security/Eval:
Enabled: false
# Offense count: 2
......
language: ruby
cache: bundler
before_install:
- gem update --system
- gem update bundler
......@@ -6,7 +7,8 @@ rvm:
- 1.9.3
- 2.0.0
- 2.1.10
- 2.2.6
- 2.3.3
- 2.4.0
- 2.2.9
- 2.3.6
- 2.4.3
- 2.5.0
- jruby-19mode
=== 4.4.4 / 2018-01-18
* Fix deprecated constant warnings on Ruby 2.5. (@mattbrictson)
=== 4.4.3 / 2016-12-28
* Fix deprecated constant warnings on Ruby 2.4.
......
[<img src="https://secure.travis-ci.org/commander-rb/commander.png?branch=master" alt="Build Status" />](http://travis-ci.org/commander-rb/commander)
[![Inline docs](http://inch-ci.org/github/commander-rb/commander.png)](http://inch-ci.org/github/commander-rb/commander)
[<img src="https://api.travis-ci.org/commander-rb/commander.svg" alt="Build Status" />](http://travis-ci.org/commander-rb/commander)
[![Inline docs](http://inch-ci.org/github/commander-rb/commander.svg)](http://inch-ci.org/github/commander-rb/commander)
# Commander
......@@ -339,6 +339,21 @@ $ foo install gem
# => installing to
```
### Long descriptions
If you need to have a long command description, keep your short description under `summary`, and consider multi-line strings for `description`:
```ruby
program :summary, 'Stupid command that prints foo or bar.'
program :description, %q(
#{c.summary}
More information about that stupid command that prints foo or bar.
And more
)
```
### Additional Global Help
Arbitrary help can be added using the following `#program` symbol:
......
# -*- encoding: utf-8 -*-
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'commander/version'
......@@ -26,6 +27,6 @@ Gem::Specification.new do |s|
s.add_development_dependency('rubocop', '~> 0.41.1')
s.add_development_dependency('json', '< 2.0')
else
s.add_development_dependency('rubocop', '~> 0.46')
s.add_development_dependency('rubocop', '~> 0.49.1')
end
end
ruby-commander (4.4.4-1) unstable; urgency=medium
* Team upload.
[ HIGUCHI Daisuke (VDR dai) ]
* New upstream release
* update upstream homepage.
* eliminate lintian warning: insecure-copyright-format-uri
* Move Vcs-* to salsa.debian.org
* Bump debhelper compatibility level to 11
* Update Standards-Version to 4.1.3
-- HIGUCHI Daisuke (VDR dai) <dai@debian.org> Sat, 17 Feb 2018 23:48:14 +0900
ruby-commander (4.4.3-1) unstable; urgency=medium
* Team upload.
......
......@@ -3,15 +3,15 @@ Section: ruby
Priority: optional
Maintainer: Debian Ruby Extras Maintainers <pkg-ruby-extras-maintainers@lists.alioth.debian.org>
Uploaders: Youhei SASAKI <uwabami@gfd-dennou.org>
Build-Depends: debhelper (>= 9~),
Build-Depends: debhelper (>= 11~),
gem2deb,
rake,
ruby-highline (>= 1.7.2),
ruby-rspec
Standards-Version: 4.1.1
Vcs-Git: https://anonscm.debian.org/git/pkg-ruby-extras/ruby-commander.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-ruby-extras/ruby-commander.git
Homepage: http://visionmedia.github.io/commander
Standards-Version: 4.1.3
Vcs-Git: https://salsa.debian.org/ruby-team/ruby-commander.git
Vcs-Browser: https://salsa.debian.org/ruby-team/ruby-commander
Homepage: https://github.com/commander-rb/commander
XS-Ruby-Versions: all
Package: ruby-commander
......
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: commander
Source: http://visionmedia.github.io/commander/
Source: https://github.com/commander-rb/commander
Files: *
Copyright: 2008-2009 TJ Holowaychuk <tj@vision-media.ca>
......
......@@ -324,22 +324,45 @@ module Commander
# Implements ask_for_CLASS methods.
module AskForClass
DEPRECATED_CONSTANTS = [:Config, :TimeoutError, :MissingSourceFile, :NIL, :TRUE, :FALSE, :Fixnum, :Bignum].freeze
# All special cases in HighLine::Question#convert, except those that implement #parse
(
[Float, Integer, String, Symbol, Regexp, Array, File, Pathname] +
# All Classes that respond to #parse
# Ignore constants that trigger deprecation warnings
(Object.constants - DEPRECATED_CONSTANTS).map do |const|
Object.const_get(const)
end.select do |const|
const.class == Class && const.respond_to?(:parse)
end
).each do |klass|
DEPRECATED_CONSTANTS = [:Config, :TimeoutError, :MissingSourceFile, :NIL, :TRUE, :FALSE, :Fixnum, :Bignum, :Data].freeze
# define methods for common classes
[Float, Integer, String, Symbol, Regexp, Array, File, Pathname].each do |klass|
define_method "ask_for_#{klass.to_s.downcase}" do |prompt|
$terminal.ask(prompt, klass)
end
end
def method_missing(method_name, *arguments, &block)
if method_name.to_s =~ /^ask_for_(.*)/
if arguments.count != 1
fail ArgumentError, "wrong number of arguments (given #{arguments.count}, expected 1)"
end
prompt = arguments.first
requested_class = Regexp.last_match[1]
# All Classes that respond to #parse
# Ignore constants that trigger deprecation warnings
available_classes = (Object.constants - DEPRECATED_CONSTANTS).map do |const|
Object.const_get(const)
end.select do |const|
const.class == Class && const.respond_to?(:parse)
end
klass = available_classes.find { |k| k.to_s.downcase == requested_class }
if klass
$terminal.ask(prompt, klass)
else
super
end
else
super
end
end
def respond_to_missing?(method_name, include_private = false)
method_name.to_s.start_with?('ask_for_') || super
end
end
##
......
module Commander
VERSION = '4.4.3'.freeze
VERSION = '4.4.4'.freeze
end
......@@ -6,8 +6,49 @@ describe Commander::Methods do
expect(subject.ancestors).to include(Commander::UI)
end
it 'includes Commander::UI::AskForClass' do
expect(subject.ancestors).to include(Commander::UI::AskForClass)
describe 'AskForClass' do
it 'includes Commander::UI::AskForClass' do
expect(subject.ancestors).to include(Commander::UI::AskForClass)
end
describe 'defining methods' do
let(:terminal) { double }
before do
allow(terminal).to receive(:ask)
$_old_terminal = $terminal
$terminal = terminal
end
after do
$terminal = $_old_terminal
end
subject do
Class.new do
include Commander::UI::AskForClass
end.new
end
it 'defines common "ask_for_*" methods' do
expect(subject.respond_to?(:ask_for_float)).to be_truthy
end
it 'responds to "ask_for_*" methods for classes that implement #parse' do
expect(subject.respond_to?(:ask_for_datetime)).to be_truthy
end
it 'fails "ask_for_*" method invocations without a prompt' do
expect do
subject.ask_for_datetime
end.to raise_error(ArgumentError)
end
it 'implements "ask_for_*"' do
expect(terminal).to receive(:ask)
subject.ask_for_datetime('hi')
end
end
end
it 'includes Commander::Delegates' do
......