diff --git a/features/steps/output_steps.rb b/features/steps/output_steps.rb index 330452a..6d23231 100644 --- a/features/steps/output_steps.rb +++ b/features/steps/output_steps.rb @@ -24,6 +24,7 @@ options: -v, --version enable verbose mode -d, --debug enable debug mode -r, --require PATH require ruby feature + -l, --layout LAYOUT specify layout eoh end diff --git a/lib/uh/wm/cli.rb b/lib/uh/wm/cli.rb index cc61bce..c52f073 100644 --- a/lib/uh/wm/cli.rb +++ b/lib/uh/wm/cli.rb @@ -63,6 +63,10 @@ module Uh require feature @env.log "Loaded `#{feature}' ruby feature" end + + opts.on '-l', '--layout LAYOUT', 'specify layout' do |layout| + @env.layout_class = self.class.const_get layout.to_sym + end end end end diff --git a/lib/uh/wm/env.rb b/lib/uh/wm/env.rb index 8c18592..fded52c 100644 --- a/lib/uh/wm/env.rb +++ b/lib/uh/wm/env.rb @@ -12,7 +12,7 @@ module Uh def_delegator :@output, :print attr_reader :output - attr_accessor :verbose, :debug + attr_accessor :verbose, :debug, :layout_class def initialize output @output = output diff --git a/spec/uh/wm/cli_spec.rb b/spec/uh/wm/cli_spec.rb index 86b4d2e..24cb07c 100644 --- a/spec/uh/wm/cli_spec.rb +++ b/spec/uh/wm/cli_spec.rb @@ -130,6 +130,15 @@ module Uh 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 let(:arguments) { %w[--unknown-option] } diff --git a/spec/uh/wm/env_spec.rb b/spec/uh/wm/env_spec.rb index ea41de3..b80334b 100644 --- a/spec/uh/wm/env_spec.rb +++ b/spec/uh/wm/env_spec.rb @@ -13,6 +13,10 @@ module Uh expect(env).not_to be_debug end + it 'has no layout_class set' do + expect(env.layout_class).not_to be + end + describe '#verbose?' do context 'when verbose mode is disabled' do before { env.verbose = false }