Class: Rbk::Cli
- Inherits:
-
Object
- Object
- Rbk::Cli
- Defined in:
- lib/rbk/cli.rb
Defined Under Namespace
Classes: Archiver
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv, options = {}) ⇒ Cli
constructor
A new instance of Cli.
- #run ⇒ Object
Constructor Details
#initialize(argv, options = {}) ⇒ Cli
Returns a new instance of Cli.
9 10 11 12 13 14 15 |
# File 'lib/rbk/cli.rb', line 9 def initialize(argv, ={}) @argv = argv @options = @git = @options[:git] || Git @github_repos = @options[:github_repos] || Github::Repos @stderr = @options[:stderr] || $stderr end |
Class Method Details
.run(argv = ARGV, options = {}) ⇒ Object
5 6 7 |
# File 'lib/rbk/cli.rb', line 5 def self.run(argv=ARGV, ={}) new(argv, ).run end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rbk/cli.rb', line 17 def run @config = Configuration.create(@argv) @config.validate @shell = @options[:shell] || Shell.new(@config.quiet?) @archiver = Archiver.new(@shell) @s3 = @options[:s3] || AWS::S3.new(@config.aws_credentials) @uploader = Uploader.new(@s3.buckets[@config.bucket], @shell) if @config.help? @shell.puts(@config.usage) else Backup.new(repos, git, archiver, uploader, shell).run end 0 rescue => e @stderr.puts(%(#{e.} (#{e.class}))) if e.is_a?(InsufficientOptionsError) @stderr.puts(@config.usage) end 1 end |