Implement recipe arguments
CLI will stop arguments processing after the special `--' argument, the rest will be saved in the env and accessible through a new task keyword: `recipe_argv'.
This commit is contained in:
@@ -130,6 +130,20 @@ module Producer::Core
|
||||
end
|
||||
end
|
||||
|
||||
context 'with recipe arguments' do
|
||||
let(:arguments) { %w[recipe.rb -- foo] }
|
||||
|
||||
it 'removes recipe arguments' do
|
||||
cli.parse_arguments!
|
||||
expect(cli.arguments).to eq %w[recipe.rb]
|
||||
end
|
||||
|
||||
it 'assigns env recipe arguments' do
|
||||
cli.parse_arguments!
|
||||
expect(cli.env.recipe_argv).to eq %w[foo]
|
||||
end
|
||||
end
|
||||
|
||||
context 'when no arguments remains after parsing' do
|
||||
let(:arguments) { [] }
|
||||
|
||||
|
@@ -179,5 +179,13 @@ module Producer::Core
|
||||
expect(task.target).to eq :some_target
|
||||
end
|
||||
end
|
||||
|
||||
describe '#recipe_argv' do
|
||||
before { env.recipe_argv = %w[foo bar] }
|
||||
|
||||
it 'returns recipe arguments' do
|
||||
expect(task.recipe_argv).to eq %w[foo bar]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user