Accept -l LAYOUT CLI option to set the layout
This commit is contained in:
parent
0ce73c2e2f
commit
b65e989c38
@ -24,6 +24,7 @@ options:
|
|||||||
-v, --version enable verbose mode
|
-v, --version enable verbose mode
|
||||||
-d, --debug enable debug mode
|
-d, --debug enable debug mode
|
||||||
-r, --require PATH require ruby feature
|
-r, --require PATH require ruby feature
|
||||||
|
-l, --layout LAYOUT specify layout
|
||||||
eoh
|
eoh
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,6 +63,10 @@ module Uh
|
|||||||
require feature
|
require feature
|
||||||
@env.log "Loaded `#{feature}' ruby feature"
|
@env.log "Loaded `#{feature}' ruby feature"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on '-l', '--layout LAYOUT', 'specify layout' do |layout|
|
||||||
|
@env.layout_class = self.class.const_get layout.to_sym
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -12,7 +12,7 @@ module Uh
|
|||||||
def_delegator :@output, :print
|
def_delegator :@output, :print
|
||||||
|
|
||||||
attr_reader :output
|
attr_reader :output
|
||||||
attr_accessor :verbose, :debug
|
attr_accessor :verbose, :debug, :layout_class
|
||||||
|
|
||||||
def initialize output
|
def initialize output
|
||||||
@output = output
|
@output = output
|
||||||
|
@ -130,6 +130,15 @@ module Uh
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with layout option' do
|
||||||
|
let(:arguments) { %w[-l Object] }
|
||||||
|
|
||||||
|
it 'assigns the layout class in the env' do
|
||||||
|
cli.parse_arguments!
|
||||||
|
expect(cli.env.layout_class).to eq Object
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'with invalid option' do
|
context 'with invalid option' do
|
||||||
let(:arguments) { %w[--unknown-option] }
|
let(:arguments) { %w[--unknown-option] }
|
||||||
|
|
||||||
|
@ -13,6 +13,10 @@ module Uh
|
|||||||
expect(env).not_to be_debug
|
expect(env).not_to be_debug
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'has no layout_class set' do
|
||||||
|
expect(env.layout_class).not_to be
|
||||||
|
end
|
||||||
|
|
||||||
describe '#verbose?' do
|
describe '#verbose?' do
|
||||||
context 'when verbose mode is disabled' do
|
context 'when verbose mode is disabled' do
|
||||||
before { env.verbose = false }
|
before { env.verbose = false }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user