Implement CLI usage feature
This commit is contained in:
@@ -2,5 +2,6 @@ require 'producer/core/version'
|
||||
|
||||
module Producer
|
||||
module Core
|
||||
autoload :CLI, 'producer/core/cli'
|
||||
end
|
||||
end
|
||||
|
27
lib/producer/core/cli.rb
Normal file
27
lib/producer/core/cli.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
module Producer
|
||||
module Core
|
||||
class CLI
|
||||
attr_reader :arguments
|
||||
|
||||
USAGE = "Usage: #{File.basename $0} host recipe_file"
|
||||
|
||||
def initialize(arguments, stdout = $stdout)
|
||||
@stdout = stdout
|
||||
@arguments = arguments
|
||||
end
|
||||
|
||||
def run!
|
||||
print_usage_and_exit(64) unless @arguments.length == 2
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def print_usage_and_exit(status)
|
||||
@stdout.puts USAGE
|
||||
|
||||
exit status
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user