Class: Prodder::CLI
- Inherits:
-
Thor
- Object
- Thor
- Prodder::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/prodder/cli.rb
Instance Method Summary collapse
- #commit(*projects) ⇒ Object
- #dump(*projects) ⇒ Object
- #init(*projects) ⇒ Object
-
#initialize(*args) ⇒ CLI
constructor
A new instance of CLI.
- #ls(*projects) ⇒ Object
- #push(*projects) ⇒ Object
Constructor Details
#initialize(*args) ⇒ CLI
Returns a new instance of CLI.
13 14 15 16 17 18 19 20 21 |
# File 'lib/prodder/cli.rb', line 13 def initialize(*args) super # Help isn't printed when we don't provide --config, which is friggin absurd. if [:config].nil? help raise Thor::RequiredArgumentMissingError, "No value provided for required option '--config'" end end |
Instance Method Details
#commit(*projects) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/prodder/cli.rb', line 52 def commit(*projects) select_projects(projects).each do |project| if project.git.dirty? puts "#{project.name}: committing changes." project.commit else puts "#{project.name}: no changes to commit." end end rescue Prodder::Git::GitError => ex puts "Failed to run '#{ex.command}':" puts ex.error exit 1 end |
#dump(*projects) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/prodder/cli.rb', line 34 def dump(*projects) select_projects(projects).each do |project| project.dump if project.git.dirty? puts "#{project.name}: updates introduced." end end rescue Prodder::Project::SeedConfigFileMissing => ex puts "No such file: #{ex.filename}" exit 1 rescue Prodder::PG::PGDumpError => ex puts ex. exit 1 end |
#init(*projects) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/prodder/cli.rb', line 24 def init(*projects) select_projects(projects).each { |project| project.init } rescue Prodder::Git::GitError => ex puts "Failed to run '#{ex.command}':" puts ex.error exit 1 end |
#ls(*projects) ⇒ Object
90 91 92 |
# File 'lib/prodder/cli.rb', line 90 def ls(*projects) config.projects.each { |project| puts project.name } end |
#push(*projects) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/prodder/cli.rb', line 69 def push(*projects) select_projects(projects).each do |project| if project.nothing_to_push? puts "#{project.name}: nothing to push." else puts "#{project.name}: pushing new commit." project.push end end rescue Prodder::Git::NotFastForward => ex puts "Refusing to push to remote #{ex.remote}: origin/master is not a fast forward from master." exit 1 rescue Prodder::Git::GitError => ex puts "Failed to run '#{ex.command}':" puts ex.error exit 1 end |