Implement CLI usage feature

This commit is contained in:
Thibault Jouan
2013-07-26 20:12:55 +00:00
parent 46f992fdb2
commit a6cfd4d7cb
5 changed files with 76 additions and 0 deletions

27
lib/producer/core/cli.rb Normal file
View 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