Module: RightPublish::CLI
- Defined in:
- lib/right_publish/cli.rb
Constant Summary collapse
- REPOSITORY_TYPES =
RepoManager.repo_types()
- SUB_COMMANDS =
%w(publish pull add annotate push)
Class Method Summary collapse
Class Method Details
.expand_argv_globs ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/right_publish/cli.rb', line 81 def self. files = [] ARGV.each do |glob| files += Dir.glob(glob) end files end |
.parse_args ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/right_publish/cli.rb', line 48 def self.parse_args() = Trollop. do version "RightPublish (c) 2013 RightScale Inc" <<-EOS RightPublish can manage a YUM/APT/RubyGem repository in remote storage, e.g. S3. Usage: right_publish [options] <command> [file1, file2, ...] basic commands: publish advanced commands: pull add annotate push options: EOS opt :local_cache, "Local cache location", :type => String opt :profile, "Publish profile", :type => String, :default => nil opt :repo_type, "Repository type: #{REPOSITORY_TYPES.keys.inspect}", :type => String opt :dist, "Target distribution. Required for binary packages. If unspecified for noarch and source packages, will copy to all distributions specified in profile.", :type => String opt :verbose, "Verbose output" end [:cmd]= ARGV.shift [:files] = Trollop.die "invalid repository type: #{[:repo_type]}" unless REPOSITORY_TYPES[[:repo_type]] end |
.run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/right_publish/cli.rb', line 8 def self.run() = parse_args begin profile = RightPublish::Profile.instance profile.load([:profile] || [:repo_type]) rescue LoadError => e puts e exit -1 end # These options override profile attributes. profile.settings[:local_storage][:cache_dir] = [:local_cache] if [:local_cache] profile.settings[:verbose] = true if [:verbose] # We already know this is a valid type, parse_args checked repo = RepoManager.get_repository(REPOSITORY_TYPES[[:repo_type]]) begin case [:cmd] when 'publish' repo.publish([:files], [:dist]) when 'pull' repo.pull when 'add' repo.add([:files], [:dist]) when 'annotate' repo.annotate when 'push' repo.push else raise ArgumentError, "Unknown command '#{[:cmd]}'" end rescue RuntimeError => e RightPublish::Profile.log("Fatal Error:\n\t#{e}", :error) exit -1 end exit 0 end |