depl 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/bin/depl +52 -17
  4. data/lib/depl/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91ac5f8b6e1641069cd6a13f1c322258608ae9c5
4
- data.tar.gz: 5d9b408b01a443bb0732c1577144e5dab7ef83b9
3
+ metadata.gz: b4eff59033859fce127ee93cf953d43e210b340a
4
+ data.tar.gz: 9782ae13f49e5d3da1eb6a6c54f4db759fcb535e
5
5
  SHA512:
6
- metadata.gz: 9d139d3d2e13866bc0c6e22a9f1ff5e0a2755a41a8e44636d5d2c7861dd10d40d9731dc923749a29c5b0b522f4bac1d3c2aba41912df62bce8efd9a9531c9fc4
7
- data.tar.gz: 56bef652df3802176b569df9602a3fe032e52e46ce881a24c43ef5c145fcebdec510027d9f04b142dcafa37a763a959d8cff6616adff2c3a7d305aebf5503ea1
6
+ metadata.gz: 4e596864ffcc42fb63728175e2f1d1021ecbfc8c83934590d890fe7a11bc9334c9fd20903419225001dcb45af54d6a22c8e88cba6e959af481246811e40ff712
7
+ data.tar.gz: 51d1ff3eb63e8391b482ca787c97f5aa02ab8b42b7a92c061f15e11e9da0174a0b292e7ad498a077d98e9c78d5d19ed4fc90bea09cdefd6d8dcb3afb31d030ab
data/README.md CHANGED
@@ -27,6 +27,7 @@ Movable Ink uses Chef to push out new code, and Chef is set up to use environmen
27
27
 
28
28
  ## History
29
29
 
30
+ * _0.0.4_ - Add --force and --quiet options; better help messages.
30
31
  * _0.0.3_ - Fixed yaml dependency.
31
32
  * _0.0.2_ - Updated gem description.
32
33
  * _0.0.1_ - Forked from deploy_s3; initial release.
data/bin/depl CHANGED
@@ -13,7 +13,7 @@ require 'colorize'
13
13
 
14
14
  options = {}
15
15
 
16
- options[:environment] = ARGV.shift
16
+ options[:environment] = ARGV.reject{|a| a =~ /^-/}.first
17
17
 
18
18
  options[:rev] = ENV['REV']
19
19
 
@@ -27,8 +27,29 @@ optparse = OptionParser.new do |opts|
27
27
  opts.on("-r", "--revision=REVISION", String, "Revision to deploy (can be sha, branch, etc)") do |r|
28
28
  options[:rev] = r
29
29
  end
30
+
31
+ opts.on("-f", "--force", "Do not ask for confirmation") do |f|
32
+ options[:force] = f
33
+ end
34
+
35
+ opts.on("-q", "--quiet", "No stdout output (only use with --force)") do |q|
36
+ options[:quiet] = q
37
+ end
38
+
39
+ opts.on("-h", "--help", "Print this help information") do |h|
40
+ if h
41
+ puts optparse
42
+ exit 1
43
+ end
44
+ end
45
+ end
46
+ begin
47
+ optparse.parse!
48
+ rescue OptionParser::InvalidOption => e
49
+ puts e.message
50
+ puts optparse
51
+ exit 1
30
52
  end
31
- optparse.parse!
32
53
 
33
54
  unless options[:environment]
34
55
  puts "Error: environment required"
@@ -36,54 +57,68 @@ unless options[:environment]
36
57
  exit 1
37
58
  end
38
59
 
60
+ def output(*msg)
61
+ puts *msg
62
+ end
63
+
64
+ if options[:force] and options[:quiet]
65
+ def output(*msg)
66
+ # no-op
67
+ end
68
+ end
69
+
39
70
  deploy = Depl::Main.new(options)
40
71
 
41
72
  if deploy.up_to_date
42
- puts "Everything up-to-date (#{deploy.environment.green}: #{deploy.remote_sha.green})"
73
+ output "Everything up-to-date (#{deploy.environment.green}: #{deploy.remote_sha.green})"
43
74
  exit 0
44
75
  end
45
76
 
46
77
  if deploy.remote_sha.nil?
47
- puts "New deployment: #{deploy.local_sha}"
78
+ output "New deployment: #{deploy.local_sha}"
48
79
  else
49
- puts "Attempting to deploy #{deploy.local_sha.bold}", ""
80
+ output "Attempting to deploy #{deploy.local_sha.bold}", ""
50
81
 
51
82
  commits = "#{deploy.commit_count} new commit(s)".green
52
- puts "Difference of #{commits} between #{deploy.remote_sha} and #{deploy.local_sha}:", ""
83
+ output "Difference of #{commits} between #{deploy.remote_sha} and #{deploy.local_sha}:", ""
53
84
 
54
85
  if deploy.commit_count > 0
55
- puts deploy.diff.yellow, ""
86
+ output deploy.diff.yellow, ""
56
87
  else
57
- puts " There are no new commits.", ""
88
+ output " There are no new commits.", ""
58
89
  end
59
90
  end
60
91
 
61
92
  if deploy.older_local_sha
62
- puts "WARNING: The commit you are deploying is older than what is currently on #{deploy.environment}. Missing commits: ".bold, ""
63
- puts deploy.reverse_diff.red
64
- puts ""
93
+ output "WARNING: The commit you are deploying is older than what is currently on #{deploy.environment}. Missing commits: ".bold, ""
94
+ output deploy.reverse_diff.red
95
+ output ""
65
96
  end
66
97
 
67
- confirm = ask("Deploy #{deploy.environment}? ([y]es / [n]o / [g]ithub) : ") { |yn| yn.limit = 1, yn.validate = /([yng]|yes|no|github)/i }
98
+ if options[:force]
99
+ confirm = 'yes'
100
+ else
101
+ confirm = ask("Deploy #{deploy.environment}? ([y]es / [n]o / [g]ithub) : ") { |yn| yn.limit = 1, yn.validate = /([yng]|yes|no|github)/i }
102
+ end
68
103
 
69
104
  case confirm.downcase
70
105
  when 'y', 'yes'
71
106
  deploy.run!
72
107
 
73
- puts "Deployed #{deploy.remote_sha}"
108
+ output "Deployed #{deploy.remote_sha}"
74
109
  when 'g', 'github'
75
110
  url = Depl::Remote.comparison(deploy.remote_sha, deploy.local_sha)
76
111
  if url
77
112
  if `which open`.size > 0
78
113
  `open #{url}`
79
114
  else
80
- puts " Github: #{url}"
115
+ output " Github: #{url}"
81
116
  end
82
117
  else
83
- puts "Unrecognized repository; can't open github"
84
- puts "(try `git config --get remote.origin.url`)"
118
+ output "Unrecognized repository; can't open github"
119
+ output "(try `git config --get remote.origin.url`)"
85
120
  exit 1
86
121
  end
87
122
  when 'n', 'no'
88
- puts "Bye."
123
+ output "Bye."
89
124
  end
@@ -1,3 +1,3 @@
1
1
  module Depl
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: depl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Nutt