commander 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +275 -0
- data/Manifest +36 -0
- data/README.rdoc +357 -0
- data/Rakefile +16 -0
- data/bin/commander +55 -0
- data/commander.gemspec +35 -0
- data/lib/commander.rb +31 -0
- data/lib/commander/blank.rb +8 -0
- data/lib/commander/command.rb +210 -0
- data/lib/commander/core_ext.rb +3 -0
- data/lib/commander/core_ext/array.rb +25 -0
- data/lib/commander/core_ext/object.rb +11 -0
- data/lib/commander/delegates.rb +13 -0
- data/lib/commander/help_formatters.rb +8 -0
- data/lib/commander/help_formatters/base.rb +18 -0
- data/lib/commander/help_formatters/terminal.rb +20 -0
- data/lib/commander/help_formatters/terminal/command_help.erb +35 -0
- data/lib/commander/help_formatters/terminal/help.erb +36 -0
- data/lib/commander/help_formatters/terminal_compact.rb +12 -0
- data/lib/commander/help_formatters/terminal_compact/command_help.erb +27 -0
- data/lib/commander/help_formatters/terminal_compact/help.erb +29 -0
- data/lib/commander/import.rb +10 -0
- data/lib/commander/runner.rb +386 -0
- data/lib/commander/user_interaction.rb +422 -0
- data/lib/commander/version.rb +4 -0
- data/spec/command_spec.rb +125 -0
- data/spec/core_ext/array_spec.rb +14 -0
- data/spec/core_ext/object_spec.rb +20 -0
- data/spec/help_formatters/base_spec.rb +24 -0
- data/spec/help_formatters/terminal_spec.rb +66 -0
- data/spec/runner_spec.rb +326 -0
- data/spec/spec_helper.rb +53 -0
- data/spec/ui_spec.rb +11 -0
- data/tasks/docs.rake +18 -0
- data/tasks/gemspec.rake +3 -0
- data/tasks/spec.rake +25 -0
- metadata +127 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
require 'commander/import'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
# Mock terminal IO streams so we can spec against them
|
7
|
+
|
8
|
+
def mock_terminal
|
9
|
+
@input = StringIO.new
|
10
|
+
@output = StringIO.new
|
11
|
+
$terminal = HighLine.new @input, @output
|
12
|
+
end
|
13
|
+
|
14
|
+
# Create test command for usage within several specs
|
15
|
+
|
16
|
+
def create_test_command
|
17
|
+
command :test do |c|
|
18
|
+
c.syntax = "test [options] <file>"
|
19
|
+
c.description = "test description"
|
20
|
+
c.example "description", "command"
|
21
|
+
c.example "description 2", "command 2"
|
22
|
+
c.option '-v', "--verbose", "verbose description"
|
23
|
+
c.when_called do |args, options|
|
24
|
+
"test %s" % args.join
|
25
|
+
end
|
26
|
+
end
|
27
|
+
@command = command :test
|
28
|
+
end
|
29
|
+
|
30
|
+
# Create a new command runner
|
31
|
+
|
32
|
+
def new_command_runner *args, &block
|
33
|
+
Commander::Runner.instance_variable_set :"@singleton", Commander::Runner.new(args)
|
34
|
+
program :name, 'test'
|
35
|
+
program :version, '1.2.3'
|
36
|
+
program :description, 'something'
|
37
|
+
create_test_command
|
38
|
+
yield if block
|
39
|
+
Commander::Runner.instance
|
40
|
+
end
|
41
|
+
|
42
|
+
# Comply with how specs were previously written
|
43
|
+
|
44
|
+
def command_runner
|
45
|
+
Commander::Runner.instance
|
46
|
+
end
|
47
|
+
|
48
|
+
def run *args
|
49
|
+
new_command_runner *args do
|
50
|
+
program :help_formatter, Commander::HelpFormatter::Base
|
51
|
+
end.run!
|
52
|
+
@output.string
|
53
|
+
end
|
data/spec/ui_spec.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
describe Commander::UI do
|
3
|
+
|
4
|
+
describe ".replace_tokens" do
|
5
|
+
it "should replace tokens within a string, with hash values" do
|
6
|
+
result = Commander::UI.replace_tokens 'Welcome :name, enjoy your :object'.freeze, :name => 'TJ', :object => 'cookie'
|
7
|
+
result.should == 'Welcome TJ, enjoy your cookie'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
data/tasks/docs.rake
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
desc 'Build docs with sdoc gem'
|
3
|
+
task :docs do
|
4
|
+
sh 'sdoc -N lib/commander'
|
5
|
+
end
|
6
|
+
|
7
|
+
namespace :docs do
|
8
|
+
|
9
|
+
desc 'Remove rdoc products'
|
10
|
+
task :remove => [:clobber_docs]
|
11
|
+
|
12
|
+
desc 'Build docs, and open in browser for viewing (specify BROWSER)'
|
13
|
+
task :open => [:docs] do
|
14
|
+
browser = ENV["BROWSER"] || "safari"
|
15
|
+
sh "open -a #{browser} doc/index.html"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/tasks/gemspec.rake
ADDED
data/tasks/spec.rake
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
desc "Run all specifications"
|
5
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
6
|
+
t.libs << "lib"
|
7
|
+
t.spec_opts = ["--color", "--require", "spec/spec_helper.rb"]
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :spec do
|
11
|
+
|
12
|
+
desc "Run all specifications verbosely"
|
13
|
+
Spec::Rake::SpecTask.new(:verbose) do |t|
|
14
|
+
t.libs << "lib"
|
15
|
+
t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Run specific specification verbosely (specify SPEC)"
|
19
|
+
Spec::Rake::SpecTask.new(:select) do |t|
|
20
|
+
t.libs << "lib"
|
21
|
+
t.spec_files = [ENV["SPEC"]]
|
22
|
+
t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: commander
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TJ Holowaychuk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-08 00:00:00 -07:00
|
13
|
+
default_executable: commander
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: highline
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.5.0
|
24
|
+
version:
|
25
|
+
description: The complete solution for Ruby command-line executables
|
26
|
+
email: tj@vision-media.ca
|
27
|
+
executables:
|
28
|
+
- commander
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.rdoc
|
33
|
+
- bin/commander
|
34
|
+
- lib/commander.rb
|
35
|
+
- lib/commander/blank.rb
|
36
|
+
- lib/commander/command.rb
|
37
|
+
- lib/commander/core_ext.rb
|
38
|
+
- lib/commander/core_ext/array.rb
|
39
|
+
- lib/commander/core_ext/object.rb
|
40
|
+
- lib/commander/delegates.rb
|
41
|
+
- lib/commander/help_formatters.rb
|
42
|
+
- lib/commander/help_formatters/base.rb
|
43
|
+
- lib/commander/help_formatters/terminal.rb
|
44
|
+
- lib/commander/help_formatters/terminal/command_help.erb
|
45
|
+
- lib/commander/help_formatters/terminal/help.erb
|
46
|
+
- lib/commander/help_formatters/terminal_compact.rb
|
47
|
+
- lib/commander/help_formatters/terminal_compact/command_help.erb
|
48
|
+
- lib/commander/help_formatters/terminal_compact/help.erb
|
49
|
+
- lib/commander/import.rb
|
50
|
+
- lib/commander/runner.rb
|
51
|
+
- lib/commander/user_interaction.rb
|
52
|
+
- lib/commander/version.rb
|
53
|
+
- tasks/docs.rake
|
54
|
+
- tasks/gemspec.rake
|
55
|
+
- tasks/spec.rake
|
56
|
+
files:
|
57
|
+
- History.rdoc
|
58
|
+
- Manifest
|
59
|
+
- README.rdoc
|
60
|
+
- Rakefile
|
61
|
+
- bin/commander
|
62
|
+
- commander.gemspec
|
63
|
+
- lib/commander.rb
|
64
|
+
- lib/commander/blank.rb
|
65
|
+
- lib/commander/command.rb
|
66
|
+
- lib/commander/core_ext.rb
|
67
|
+
- lib/commander/core_ext/array.rb
|
68
|
+
- lib/commander/core_ext/object.rb
|
69
|
+
- lib/commander/delegates.rb
|
70
|
+
- lib/commander/help_formatters.rb
|
71
|
+
- lib/commander/help_formatters/base.rb
|
72
|
+
- lib/commander/help_formatters/terminal.rb
|
73
|
+
- lib/commander/help_formatters/terminal/command_help.erb
|
74
|
+
- lib/commander/help_formatters/terminal/help.erb
|
75
|
+
- lib/commander/help_formatters/terminal_compact.rb
|
76
|
+
- lib/commander/help_formatters/terminal_compact/command_help.erb
|
77
|
+
- lib/commander/help_formatters/terminal_compact/help.erb
|
78
|
+
- lib/commander/import.rb
|
79
|
+
- lib/commander/runner.rb
|
80
|
+
- lib/commander/user_interaction.rb
|
81
|
+
- lib/commander/version.rb
|
82
|
+
- spec/command_spec.rb
|
83
|
+
- spec/core_ext/array_spec.rb
|
84
|
+
- spec/core_ext/object_spec.rb
|
85
|
+
- spec/help_formatters/base_spec.rb
|
86
|
+
- spec/help_formatters/terminal_spec.rb
|
87
|
+
- spec/runner_spec.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
- spec/ui_spec.rb
|
90
|
+
- tasks/docs.rake
|
91
|
+
- tasks/gemspec.rake
|
92
|
+
- tasks/spec.rake
|
93
|
+
has_rdoc: true
|
94
|
+
homepage: http://visionmedia.github.com/commander
|
95
|
+
licenses: []
|
96
|
+
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options:
|
99
|
+
- --line-numbers
|
100
|
+
- --inline-source
|
101
|
+
- --title
|
102
|
+
- Commander
|
103
|
+
- --main
|
104
|
+
- README.rdoc
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: "0"
|
112
|
+
version:
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: "1.2"
|
118
|
+
version:
|
119
|
+
requirements: []
|
120
|
+
|
121
|
+
rubyforge_project: commander
|
122
|
+
rubygems_version: 1.3.5
|
123
|
+
signing_key:
|
124
|
+
specification_version: 3
|
125
|
+
summary: The complete solution for Ruby command-line executables
|
126
|
+
test_files: []
|
127
|
+
|