hobo-inviqa 0.0.6 → 0.0.7.pre.rc1
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 +15 -0
- data/.editorconfig +10 -0
- data/Gemfile.lock +7 -3
- data/Guardfile +2 -2
- data/Hobofile +5 -1
- data/bin/hobo +12 -18
- data/hobo.gemspec +2 -0
- data/lib/hobo.rb +8 -1
- data/lib/hobo/cli.rb +14 -4
- data/lib/hobo/config/file.rb +1 -1
- data/lib/hobo/error_handlers/debug.rb +5 -2
- data/lib/hobo/error_handlers/exit_code_map.rb +16 -0
- data/lib/hobo/error_handlers/friendly.rb +13 -8
- data/lib/hobo/errors.rb +11 -1
- data/lib/hobo/helper/http_download.rb +41 -0
- data/lib/hobo/helper/shell.rb +21 -5
- data/lib/hobo/helper/vm_command.rb +127 -17
- data/lib/hobo/lib/host_check.rb +20 -6
- data/lib/hobo/lib/host_check/deps.rb +22 -4
- data/lib/hobo/lib/host_check/git.rb +41 -17
- data/lib/hobo/lib/host_check/ruby.rb +30 -20
- data/lib/hobo/lib/host_check/vagrant.rb +37 -6
- data/lib/hobo/lib/s3sync.rb +23 -40
- data/lib/hobo/lib/seed/project.rb +8 -1
- data/lib/hobo/lib/seed/seed.rb +15 -3
- data/lib/hobo/patches/slop.rb +21 -2
- data/lib/hobo/tasks/assets.rb +32 -20
- data/lib/hobo/tasks/config.rb +15 -0
- data/lib/hobo/tasks/deps.rb +29 -4
- data/lib/hobo/tasks/seed.rb +1 -1
- data/lib/hobo/tasks/system.rb +15 -0
- data/lib/hobo/tasks/system/completions.rb +76 -0
- data/lib/hobo/tasks/tools.rb +10 -6
- data/lib/hobo/tasks/vm.rb +74 -6
- data/lib/hobo/ui.rb +27 -10
- data/lib/hobo/util.rb +36 -2
- data/lib/hobo/version.rb +2 -2
- data/spec/hobo/asset_applicator_spec.rb +2 -2
- data/spec/hobo/cli_spec.rb +35 -24
- data/spec/hobo/config/file_spec.rb +1 -3
- data/spec/hobo/error_handlers/debug_spec.rb +39 -5
- data/spec/hobo/error_handlers/friendly_spec.rb +38 -21
- data/spec/hobo/help_formatter_spec.rb +3 -3
- data/spec/hobo/helpers/file_locator_spec.rb +2 -2
- data/spec/hobo/helpers/shell_spec.rb +2 -2
- data/spec/hobo/helpers/vm_command_spec.rb +36 -24
- data/spec/hobo/lib/s3sync_spec.rb +6 -3
- data/spec/hobo/lib/seed/project_spec.rb +2 -3
- data/spec/hobo/lib/seed/replacer_spec.rb +1 -2
- data/spec/hobo/lib/seed/seed_spec.rb +2 -3
- data/spec/hobo/logging_spec.rb +2 -2
- data/spec/hobo/metadata_spec.rb +2 -2
- data/spec/hobo/null_spec.rb +2 -2
- data/spec/hobo/paths_spec.rb +1 -2
- data/spec/hobo/ui_spec.rb +104 -20
- data/spec/hobo/util_spec.rb +75 -0
- data/spec/spec_helper.rb +1 -0
- metadata +43 -49
- data/lib/hobo/tasks/console.rb +0 -18
- data/lib/hobo/tasks/host.rb +0 -17
@@ -0,0 +1,15 @@
|
|
1
|
+
desc "System configuration related commands"
|
2
|
+
namespace :system do
|
3
|
+
|
4
|
+
desc "Check system configuration for potential problems"
|
5
|
+
task :check do
|
6
|
+
Hobo::Lib::HostCheck.check.each do |k,v|
|
7
|
+
if v == :ok
|
8
|
+
Hobo.ui.success "#{k}: OK"
|
9
|
+
else
|
10
|
+
Hobo.ui.error "#{k}: FAILED\n"
|
11
|
+
Hobo.ui.warning v.advice.gsub(/^/, ' ')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
desc "System configuration related commands"
|
2
|
+
namespace :system do
|
3
|
+
|
4
|
+
desc "Shell completion related commands"
|
5
|
+
namespace :completions do
|
6
|
+
|
7
|
+
desc "Install shell completion helpers"
|
8
|
+
option '-f', '--fish', 'Install completions for FISH'
|
9
|
+
option '-b', '--bash', 'Install completions for Bash'
|
10
|
+
option '-z', '--zsh', 'Install completions for ZSH'
|
11
|
+
task "install" do |task|
|
12
|
+
if task.opts[:fish]
|
13
|
+
script = <<-EOF
|
14
|
+
function __hobo_completion -d "Create hobo completions"
|
15
|
+
set -l cache_dir "/tmp/fish_hobo_completion_cache"
|
16
|
+
mkdir -p $cache_dir
|
17
|
+
set -l hashed_pwd (ruby -r 'digest' -e 'puts Digest::MD5.hexdigest(`pwd`)')
|
18
|
+
set -l hobo_cache_file "$cache_dir/$hashed_pwd"
|
19
|
+
|
20
|
+
if not test -f "$hobo_cache_file"
|
21
|
+
hobo system completions fish > "$hobo_cache_file"
|
22
|
+
end
|
23
|
+
|
24
|
+
cat "$hobo_cache_file"
|
25
|
+
end
|
26
|
+
|
27
|
+
function __hobo_scope_test -d "Hobo scoped completion test"
|
28
|
+
set cmd (commandline -opc)
|
29
|
+
if [ "$cmd" = "$argv" ]
|
30
|
+
return 0
|
31
|
+
end
|
32
|
+
return 1
|
33
|
+
end
|
34
|
+
|
35
|
+
eval (__hobo_completion)
|
36
|
+
EOF
|
37
|
+
target = File.join(ENV['HOME'], '.config/fish/completions/hobo.fish')
|
38
|
+
FileUtils.mkdir_p(File.dirname(target))
|
39
|
+
File.write(target, script)
|
40
|
+
end
|
41
|
+
|
42
|
+
if task.opts[:bash]
|
43
|
+
raise "Bash completions not yet implemented"
|
44
|
+
end
|
45
|
+
|
46
|
+
if task.opts[:zsh]
|
47
|
+
raise "ZSH completions not yet implemented"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "Display FISH shell completion commands"
|
52
|
+
task :fish do
|
53
|
+
Hobo.cli.slop.options.each do |option|
|
54
|
+
short = option.short.nil? ? '' : "-s #{option.short}"
|
55
|
+
long = option.long.nil? ? '' : "-l #{option.long}"
|
56
|
+
arg = option.config[:argument] ? '' : '-x'
|
57
|
+
puts "complete #{arg} -c hobo #{short} #{long} --description '#{option.description}';"
|
58
|
+
end
|
59
|
+
|
60
|
+
map = Hobo.cli.help_formatter.command_map
|
61
|
+
map.each do |k, v|
|
62
|
+
next if v.description.nil? || v.description.empty?
|
63
|
+
k = k.split(':')
|
64
|
+
k.unshift 'hobo'
|
65
|
+
c = k.pop
|
66
|
+
puts "complete -x -c hobo -n '__hobo_scope_test #{k.join(' ')}' -a #{c} --description '#{v.description}';"
|
67
|
+
v.options.each do |option|
|
68
|
+
short = option.short.nil? ? '' : "-s #{option.short}"
|
69
|
+
long = option.long.nil? ? '' : "-l #{option.long}"
|
70
|
+
arg = option.config[:argument] ? '' : '-x'
|
71
|
+
puts "complete #{arg} -c hobo -n '__hobo_scope_test #{k.concat([c]).join(' ')}' #{short} #{long} --description '#{option.description}';"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/hobo/tasks/tools.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
+
desc "Tasks to retrieve common tools"
|
2
|
+
hidden
|
1
3
|
namespace :tools do
|
4
|
+
|
5
|
+
desc "Fetch composer"
|
2
6
|
task :composer do
|
3
7
|
bin_file = File.join(Hobo.project_bin_path, "composer.phar")
|
4
8
|
unless File.exists?(bin_file)
|
5
|
-
Hobo.ui.success "Getting composer
|
9
|
+
Hobo.ui.success "Getting composer"
|
6
10
|
FileUtils.mkdir_p File.dirname(bin_file)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
Hobo.ui.separator
|
11
|
+
vm_shell "cd bin && php -r \"readfile('https://getcomposer.org/installer');\" | php", :realtime => true, :indent => 2
|
12
|
+
else
|
13
|
+
Hobo.ui.success "Composer already available in bin/composer.phar"
|
11
14
|
end
|
15
|
+
Hobo.ui.separator
|
12
16
|
end
|
13
|
-
end
|
17
|
+
end
|
data/lib/hobo/tasks/vm.rb
CHANGED
@@ -7,14 +7,43 @@ namespace :vm do
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
def vagrant_exec *args
|
11
|
+
opts = { :realtime => true, :indent => 2 }
|
12
|
+
color = Hobo.ui.supports_color? ? '--color' : '--no-color'
|
13
|
+
|
14
|
+
if OS.windows?
|
15
|
+
opts[:env] = { 'VAGRANT_HOME' => windows_short(dir) } if ENV['HOME'].match(/\s+/) && !ENV['VAGRANT_HOME']
|
16
|
+
end
|
17
|
+
|
18
|
+
args.unshift 'vagrant'
|
19
|
+
args.push color
|
20
|
+
args.push opts
|
21
|
+
|
22
|
+
bundle_shell *args
|
23
|
+
end
|
24
|
+
|
25
|
+
def windows_short dir
|
26
|
+
segments = dir.gsub(/\\/, '/').split('/')
|
27
|
+
segments.map do |segment|
|
28
|
+
if segment.match /\s+/
|
29
|
+
# This may fail in some edge cases but better than naught
|
30
|
+
# See the following link for the correct solution
|
31
|
+
# http://stackoverflow.com/questions/10224572/convert-long-filename-to-short-filename-8-3
|
32
|
+
segment.upcase.gsub(/\s+/, '')[0...6] + '~1'
|
33
|
+
else
|
34
|
+
segment
|
35
|
+
end
|
36
|
+
end.join('/')
|
37
|
+
end
|
38
|
+
|
10
39
|
desc "Start & provision VM"
|
11
|
-
task :up => [ 'deps:chef', '
|
40
|
+
task :up => [ 'deps:chef', 'assets:download', 'vm:start', 'vm:provision', 'deps:composer', 'assets:apply' ]
|
12
41
|
|
13
42
|
desc "Stop VM"
|
14
43
|
task :stop => [ "deps:gems" ] do
|
15
44
|
vagrantfile do
|
16
45
|
Hobo.ui.title "Stopping VM"
|
17
|
-
|
46
|
+
vagrant_exec 'suspend'
|
18
47
|
Hobo.ui.separator
|
19
48
|
end
|
20
49
|
end
|
@@ -26,7 +55,7 @@ namespace :vm do
|
|
26
55
|
task :destroy => [ "deps:gems" ] do
|
27
56
|
vagrantfile do
|
28
57
|
Hobo.ui.title "Destroying VM"
|
29
|
-
|
58
|
+
vagrant_exec 'destroy', '--force'
|
30
59
|
Hobo.ui.separator
|
31
60
|
end
|
32
61
|
end
|
@@ -35,7 +64,7 @@ namespace :vm do
|
|
35
64
|
task :start => [ "deps:gems", "deps:vagrant_plugins" ] do
|
36
65
|
vagrantfile do
|
37
66
|
Hobo.ui.title "Starting vagrant VM"
|
38
|
-
|
67
|
+
vagrant_exec 'up', '--no-provision'
|
39
68
|
Hobo.ui.separator
|
40
69
|
end
|
41
70
|
end
|
@@ -44,8 +73,47 @@ namespace :vm do
|
|
44
73
|
task :provision => [ "deps:gems" ] do
|
45
74
|
vagrantfile do
|
46
75
|
Hobo.ui.title "Provisioning VM"
|
47
|
-
|
76
|
+
vagrant_exec 'provision'
|
48
77
|
Hobo.ui.separator
|
49
78
|
end
|
50
79
|
end
|
51
|
-
|
80
|
+
|
81
|
+
desc "Open an SSH connection"
|
82
|
+
task :ssh do |task|
|
83
|
+
execute = task.opts[:_unparsed]
|
84
|
+
opts = { :psuedo_tty => STDIN.tty? }
|
85
|
+
|
86
|
+
Hobo.ui.success "Determining VM connection details..." if STDOUT.tty?
|
87
|
+
command = execute.empty? ? vm_command(nil, opts) : vm_command(execute, opts)
|
88
|
+
Hobo.logger.debug "vm:ssh: #{command}"
|
89
|
+
|
90
|
+
Hobo.ui.success "Connecting..." if STDOUT.tty?
|
91
|
+
exec command
|
92
|
+
end
|
93
|
+
|
94
|
+
desc "Open a MySQL cli connection"
|
95
|
+
option '-D=', '--db=', 'Database'
|
96
|
+
task :mysql do |task|
|
97
|
+
opts = { :psuedo_tty => STDIN.tty? }
|
98
|
+
opts[:db] = task.opts[:db] if task.opts[:db]
|
99
|
+
|
100
|
+
Hobo.ui.success "Determining VM connection details..." if STDOUT.tty?
|
101
|
+
command = vm_mysql(opts)
|
102
|
+
Hobo.logger.debug "vm:mysql: #{command}"
|
103
|
+
|
104
|
+
Hobo.ui.success "Connecting..." if STDOUT.tty?
|
105
|
+
exec command
|
106
|
+
end
|
107
|
+
|
108
|
+
desc "Open a Redis cli connection"
|
109
|
+
task :redis do
|
110
|
+
opts = { :psuedo_tty => STDIN.tty? }
|
111
|
+
|
112
|
+
Hobo.ui.success "Determining VM connection details..." if STDOUT.tty?
|
113
|
+
command = vm_command("redis-cli", opts)
|
114
|
+
Hobo.logger.debug "vm:redis: #{command}"
|
115
|
+
|
116
|
+
Hobo.ui.success "Connecting..." if STDOUT.tty?
|
117
|
+
exec command
|
118
|
+
end
|
119
|
+
end
|
data/lib/hobo/ui.rb
CHANGED
@@ -6,6 +6,8 @@ module Hobo
|
|
6
6
|
end
|
7
7
|
|
8
8
|
class Ui
|
9
|
+
include Hobo::Logging
|
10
|
+
|
9
11
|
attr_accessor :interactive
|
10
12
|
|
11
13
|
COLORS = {
|
@@ -22,10 +24,12 @@ module Hobo
|
|
22
24
|
:description => [:bold]
|
23
25
|
}
|
24
26
|
|
25
|
-
def initialize
|
27
|
+
def initialize input = $stdin, output = $stdout, error = $stderr
|
26
28
|
HighLine.color_scheme = HighLine::ColorScheme.new COLORS
|
27
|
-
@
|
28
|
-
@
|
29
|
+
@output_io = output
|
30
|
+
@out = ::HighLine.new input, output
|
31
|
+
@error = ::HighLine.new input, error
|
32
|
+
use_color supports_color?
|
29
33
|
end
|
30
34
|
|
31
35
|
def color_scheme scheme = nil
|
@@ -33,15 +37,25 @@ module Hobo
|
|
33
37
|
HighLine.color_scheme
|
34
38
|
end
|
35
39
|
|
40
|
+
def supports_color?
|
41
|
+
return @output_io.tty? unless OS.windows?
|
42
|
+
return (ENV['ANSICON'] || ENV['TERM'] == 'xterm') && @output_io.tty? # ANSICON or MinTTY && output is TTY
|
43
|
+
end
|
44
|
+
|
36
45
|
def use_color opt = nil
|
37
46
|
HighLine.use_color = opt unless opt.nil?
|
38
47
|
HighLine.use_color?
|
39
48
|
end
|
40
49
|
|
41
50
|
def ask question, opts = {}
|
42
|
-
|
43
|
-
|
44
|
-
|
51
|
+
opts = {
|
52
|
+
:validate => nil,
|
53
|
+
:default => nil
|
54
|
+
}.merge(opts)
|
55
|
+
|
56
|
+
unless @interactive
|
57
|
+
raise Hobo::NonInteractiveError.new(question) if opts[:default].nil?
|
58
|
+
return opts[:default].to_s
|
45
59
|
end
|
46
60
|
|
47
61
|
question = "#{question} [#{opts[:default]}]" if opts[:default]
|
@@ -51,7 +65,8 @@ module Hobo
|
|
51
65
|
q.validate = opts[:validate] if opts[:validate]
|
52
66
|
q.readline
|
53
67
|
end
|
54
|
-
answer
|
68
|
+
answer = answer.to_s
|
69
|
+
answer.strip.empty? ? opts[:default].to_s : answer.strip
|
55
70
|
rescue EOFError
|
56
71
|
Hobo.ui.info ""
|
57
72
|
""
|
@@ -65,7 +80,7 @@ module Hobo
|
|
65
80
|
end
|
66
81
|
|
67
82
|
def separator
|
68
|
-
info ""
|
83
|
+
info(supports_color? ? "" : "\n")
|
69
84
|
end
|
70
85
|
|
71
86
|
def color *args
|
@@ -100,7 +115,9 @@ module Hobo
|
|
100
115
|
|
101
116
|
def say channel, message, color
|
102
117
|
return if message.nil?
|
103
|
-
|
118
|
+
message = color ? channel.color(message, color) : message
|
119
|
+
channel.say(message) unless logger.level <= Logger::DEBUG
|
120
|
+
logger.debug(message)
|
104
121
|
end
|
105
122
|
end
|
106
|
-
end
|
123
|
+
end
|
data/lib/hobo/util.rb
CHANGED
@@ -1,7 +1,41 @@
|
|
1
|
+
require 'ruby-progressbar'
|
2
|
+
|
1
3
|
module Hobo
|
2
4
|
class << self
|
5
|
+
|
6
|
+
attr_accessor :project_bar_cache
|
7
|
+
|
3
8
|
def in_project?
|
4
|
-
|
9
|
+
!!Hobo.project_path
|
10
|
+
end
|
11
|
+
|
12
|
+
def progress file, increment, total, type, opts = {}
|
13
|
+
opts = {
|
14
|
+
:title => File.basename(file),
|
15
|
+
:total => total,
|
16
|
+
:format => "%t [%B] %p%% %e"
|
17
|
+
}.merge(opts)
|
18
|
+
|
19
|
+
# Hack to stop newline spam on windows
|
20
|
+
opts[:length] = 79 if Gem::win_platform?
|
21
|
+
|
22
|
+
@progress_bar_cache ||= {}
|
23
|
+
|
24
|
+
if type == :reset
|
25
|
+
type = :update
|
26
|
+
@progress_bar_cache.delete file
|
27
|
+
end
|
28
|
+
|
29
|
+
@progress_bar_cache[file] ||= ProgressBar.create(opts)
|
30
|
+
|
31
|
+
case type
|
32
|
+
when :update
|
33
|
+
@progress_bar_cache[file].progress += increment
|
34
|
+
when :finished
|
35
|
+
@progress_bar_cache[file].finish
|
36
|
+
end
|
37
|
+
|
38
|
+
return @progress_bar_cache[file]
|
5
39
|
end
|
6
40
|
end
|
7
|
-
end
|
41
|
+
end
|
data/lib/hobo/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Hobo
|
2
|
-
VERSION = '0.0.
|
3
|
-
end
|
2
|
+
VERSION = '0.0.7-rc1'
|
3
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Hobo::AssetApplicatorRegistry do
|
4
4
|
describe "asset_applicators accessor" do
|
@@ -28,4 +28,4 @@ describe Hobo::AssetApplicatorRegistry do
|
|
28
28
|
registry["abc"].call.should match "block"
|
29
29
|
end
|
30
30
|
end
|
31
|
-
end
|
31
|
+
end
|
data/spec/hobo/cli_spec.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'rake'
|
3
|
-
require 'hobo'
|
4
2
|
|
5
3
|
describe Hobo::Cli do
|
6
4
|
cli = nil
|
7
5
|
help = nil
|
8
6
|
hobofile = nil
|
9
7
|
|
8
|
+
def test_args args
|
9
|
+
args.concat(['--skip-host-checks'])
|
10
|
+
end
|
11
|
+
|
10
12
|
before do
|
11
13
|
Rake::Task.tasks.each do |task|
|
12
14
|
task.clear
|
13
15
|
end
|
16
|
+
|
14
17
|
Hobo.ui = double(Hobo::Ui).as_null_object
|
15
18
|
help = double(Hobo::HelpFormatter).as_null_object
|
16
19
|
cli = Hobo::Cli.new help: help
|
@@ -21,6 +24,8 @@ describe Hobo::Cli do
|
|
21
24
|
FakeFS.activate!
|
22
25
|
|
23
26
|
File.write('Hobofile', hobofile)
|
27
|
+
|
28
|
+
double(Hobo::Lib::HostCheck).as_null_object
|
24
29
|
end
|
25
30
|
|
26
31
|
after do
|
@@ -29,61 +34,61 @@ describe Hobo::Cli do
|
|
29
34
|
end
|
30
35
|
|
31
36
|
it "should load the hobofile if present" do
|
32
|
-
cli.start []
|
37
|
+
cli.start test_args([])
|
33
38
|
Rake::Task["test:non-interactive"].should_not be nil
|
34
39
|
end
|
35
40
|
|
36
41
|
it "should load the user hobofile if present" do
|
37
42
|
FileUtils.mkdir_p(File.dirname(Hobo.user_hobofile_path))
|
38
43
|
File.write(Hobo.user_hobofile_path, "namespace :user do\ntask :user do\nend\nend")
|
39
|
-
cli.start []
|
44
|
+
cli.start test_args([])
|
40
45
|
Rake::Task["user:user"].should_not be nil
|
41
46
|
end
|
42
47
|
|
43
48
|
it "should load project config if present" do
|
44
49
|
FileUtils.mkdir_p("tools/hobo/")
|
45
50
|
File.write("tools/hobo/config.yaml", YAML::dump({ :project => "project_config" }))
|
46
|
-
cli.start []
|
51
|
+
cli.start test_args([])
|
47
52
|
Hobo.project_config.project.should match "project_config"
|
48
53
|
end
|
49
54
|
|
50
55
|
it "should load user config if present" do
|
51
56
|
FileUtils.mkdir_p(Hobo.config_path)
|
52
57
|
File.write(Hobo.user_config_file, YAML::dump({ :user => "user_config" }))
|
53
|
-
cli.start []
|
58
|
+
cli.start test_args([])
|
54
59
|
Hobo.user_config.user.should match "user_config"
|
55
60
|
end
|
56
61
|
|
57
62
|
it "should set command map on help formatter" do
|
58
63
|
help.should_recieve('command_map=')
|
59
|
-
cli.start ["test", "subcommand"]
|
64
|
+
cli.start test_args(["test", "subcommand"])
|
60
65
|
end
|
61
66
|
|
62
67
|
it "should propagate description metadata" do
|
63
68
|
map = nil
|
64
69
|
allow(help).to receive("command_map=") { |i| map = i }
|
65
|
-
cli.start []
|
70
|
+
cli.start test_args([])
|
66
71
|
map["test:metadata"].description.should match "description"
|
67
72
|
end
|
68
73
|
|
69
74
|
it "should propagate long description metadata" do
|
70
75
|
map = nil
|
71
76
|
allow(help).to receive("command_map=") { |i| map = i }
|
72
|
-
cli.start []
|
77
|
+
cli.start test_args([])
|
73
78
|
map["test:metadata"].long_description.should match "long description"
|
74
79
|
end
|
75
80
|
|
76
81
|
it "should propagate arg list metadata" do
|
77
82
|
map = nil
|
78
83
|
allow(help).to receive("command_map=") { |i| map = i }
|
79
|
-
cli.start []
|
84
|
+
cli.start test_args([])
|
80
85
|
expect(map["test:metadata"].arg_list).to eq [ :arg ]
|
81
86
|
end
|
82
87
|
|
83
88
|
it "should propagate option metadata" do
|
84
89
|
map = nil
|
85
90
|
allow(help).to receive("command_map=") { |i| map = i }
|
86
|
-
cli.start []
|
91
|
+
cli.start test_args([])
|
87
92
|
map["test:metadata"].options.length.should be 2
|
88
93
|
expect(map["test:metadata"].options.map(&:short)).to eq [ 'o', 'h' ]
|
89
94
|
expect(map["test:metadata"].options.map(&:long)).to eq [ 'option', 'help' ]
|
@@ -93,61 +98,67 @@ describe Hobo::Cli do
|
|
93
98
|
it "should propagate hidden metadata" do
|
94
99
|
map = nil
|
95
100
|
allow(help).to receive("command_map=") { |i| map = i }
|
96
|
-
cli.start []
|
101
|
+
cli.start test_args([])
|
97
102
|
map["test:metadata"].hidden.should be true
|
98
103
|
end
|
99
104
|
|
100
105
|
it "should set non-interactive mode in ui if --non-interactive" do
|
101
106
|
Hobo.ui.should_receive('interactive=').with(false)
|
102
|
-
cli.start(['--non-interactive'])
|
107
|
+
cli.start(test_args(['--non-interactive']))
|
103
108
|
end
|
104
109
|
|
105
110
|
it "should show help if no args or opts passed" do
|
106
111
|
help.should_receive(:help)
|
107
|
-
cli.start([])
|
112
|
+
cli.start(test_args([]))
|
108
113
|
end
|
109
114
|
|
110
115
|
it "should show help for --help" do
|
111
116
|
help.should_receive(:help)
|
112
|
-
cli.start ["--help"]
|
117
|
+
cli.start test_args(["--help"])
|
113
118
|
end
|
114
119
|
|
115
120
|
it "should execute a top level command" do
|
116
121
|
Hobo.ui.should_recieve(:info).with("top level")
|
117
|
-
cli.start ["top-level"]
|
122
|
+
cli.start test_args(["top-level"])
|
118
123
|
end
|
119
124
|
|
120
125
|
it "should execute a subcommand" do
|
121
126
|
Hobo.ui.should_recieve(:info).with("Subcommand test")
|
122
|
-
cli.start ["test", "subcommand"]
|
127
|
+
cli.start test_args(["test", "subcommand"])
|
123
128
|
end
|
124
129
|
|
125
130
|
it "should show help for a namespace" do
|
126
131
|
help.should_receive(:help).with(all: nil, target: "test")
|
127
|
-
cli.start ["test"]
|
132
|
+
cli.start test_args(["test"])
|
128
133
|
end
|
129
134
|
|
130
135
|
it "should show command help for --help" do
|
131
136
|
help.should_receive(:help).with(all: nil, target: "test:subcommand")
|
132
|
-
cli.start ["test", "subcommand", "--help"]
|
137
|
+
cli.start test_args(["test", "subcommand", "--help"])
|
133
138
|
end
|
134
139
|
|
135
140
|
it "should propagate --all option to help" do
|
136
141
|
help.should_receive(:help).with(all: true, target: "test")
|
137
|
-
cli.start ["test", "--all"]
|
142
|
+
cli.start test_args(["test", "--all"])
|
138
143
|
end
|
139
144
|
|
140
145
|
it "should propagate command opts to command" do
|
141
146
|
Hobo.ui.should_receive(:info).with("1234")
|
142
|
-
cli.start ["test", "option-test", "--testing=1234"]
|
147
|
+
cli.start test_args(["test", "option-test", "--testing=1234"])
|
143
148
|
end
|
144
149
|
|
145
150
|
it "should propagate arguments to command" do
|
146
151
|
Hobo.ui.should_receive(:info).with("1234")
|
147
|
-
cli.start ["test", "argument-test", "1234"]
|
152
|
+
cli.start test_args(["test", "argument-test", "1234"])
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should propagate unparsed arguments in :_unparsed opt" do
|
156
|
+
Hobo.ui.should_receive(:info).with("ls --help")
|
157
|
+
cli.slop.unparsed = "ls --help"
|
158
|
+
cli.start test_args(["test", "unparsed", "--skip-host-checks"])
|
148
159
|
end
|
149
160
|
|
150
161
|
it "should raise an exception if not enough arguments were passed" do
|
151
|
-
expect { cli.start(["test", "metadata"]) }.to raise_error Hobo::MissingArgumentsError
|
162
|
+
expect { cli.start(test_args(["test", "metadata"])) }.to raise_error Hobo::MissingArgumentsError
|
152
163
|
end
|
153
|
-
end
|
164
|
+
end
|