lux 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9064cd42c7698352abe3e9f1db29d000ef4c4a7f
4
- data.tar.gz: f26172a2ccc61f7fa5bac8954166018ce13e0669
3
+ metadata.gz: 2d80091c120733bc4bb30d9d551fecfb1b19e19d
4
+ data.tar.gz: 188b53c0ceed1fd37894980fd9f9d4195b8f0647
5
5
  SHA512:
6
- metadata.gz: c9b02b28acd7a97fc1700a8673a1439a779c6930ad9f19d375a4257534fb0b7d4e2f64dbc6769b54f048507a01a8a6d5ce69a9cb9dfbfa91e40e668a355a2fb8
7
- data.tar.gz: 0e58a3fa9232ac288f3df161ee3d259e55b78ae746c5ade739379b0b96a0745d212892ed5b95727929329f61a3e20c0d7822c51b6b631cb79723ed25c93218f9
6
+ metadata.gz: 6d1e9a3ce52dcda546b0c1f43c903836239a670eeb8e059f55d32747636c67de3260f659f01d04e6ad7b2570b8aecff06a86d660baabed4a1795649dcca8387b
7
+ data.tar.gz: 84e506beedb7a83921a6e0e097f56a519d6496757a88779cdea55686fe31ea9a5c45d3cc8cfcfc9f3f4d8b35d62ec2c3b33b593bd169705efd58a2ce0caf60d7
data/README.md CHANGED
@@ -5,6 +5,8 @@ Shining some light on setting up and running various Docker things.
5
5
  Lux is both a command line tool (based on Thor) and a library of useful routines
6
6
  that can be included in Rake tasks.
7
7
 
8
+ [![Gem Version](https://img.shields.io/gem/v/lux.svg?style=flat)][gem]
9
+
8
10
  ## Installation
9
11
 
10
12
  Add this line to your application's Gemfile:
data/bin/lux CHANGED
@@ -3,4 +3,9 @@
3
3
  require "bundler/setup"
4
4
  require "lux"
5
5
 
6
+ trap("INT") do
7
+ print "\n"
8
+ exit(1)
9
+ end
10
+
6
11
  Lux::App.start(ARGV)
data/lib/lux.rb CHANGED
@@ -1,14 +1,20 @@
1
1
  require "lux/version"
2
2
  require 'pathname'
3
+ require 'highline/import'
3
4
  require 'shellwords'
4
5
  require 'thor'
5
6
  require 'uri'
6
7
 
7
- class Lux::App < Thor
8
-
9
8
  # The Thor subclass containing useful tasks shared between the Lux
10
9
  # standalone executable and Rake tasks.
11
10
  #
11
+ class Lux::App < Thor
12
+
13
+ desc "version", "Show the version"
14
+ def version
15
+ puts "Version #{Lux::VERSION}"
16
+ end
17
+
12
18
  desc "check", "Check the integrity of the Git repositories"
13
19
  def check
14
20
  repobranch = `git symbolic-ref -q HEAD`.chomp.gsub(%r{^.*/},'')
@@ -21,16 +27,16 @@ class Lux::App < Thor
21
27
  die "Bad submodule status #{s}" unless /^(?<flag>[-+U\s])(?<sha>[0-9a-f]{40})\s(?<path>\S+)(\s*\((?<ref>\S+)\))?$/ =~ s
22
28
  case flag
23
29
  when '-'
24
- puts "Submodule at #{path} is not initialized!"
30
+ Highline.say "Submodule at #{path} is <%= color('not initialized', RED) %>!"
25
31
  nModuleWarn += 1
26
32
  when '+'
27
- puts "Submodule at #{path} is not at correct commit!"
33
+ Highline.say "Submodule at #{path} is <%= color('not at correct commit', RED) %>!"
28
34
  nModuleErr += 1
29
35
  when 'U'
30
- puts "Submodule at #{path} is conflicted!"
36
+ Highline.say "Submodule at #{path} is <%= color('conflicted', RED) %>!"
31
37
  nModuleErr += 1
32
38
  else
33
- puts "Submodule at #{path} OK"
39
+ Highline.say "Submodule at #{path} is <%= color('OK', GREEN) %>"
34
40
  end
35
41
  [path, [flag, sha, ref]]
36
42
  end ]
@@ -43,7 +49,7 @@ class Lux::App < Thor
43
49
  if changes.size > 0
44
50
  die "Repository is not clean (#{changes.size} issues), use 'git status'"
45
51
  else
46
- puts "Repository is clean"
52
+ HighLine.say "<%= color('Repository is clean', GREEN) %>"
47
53
  end
48
54
  end
49
55
 
@@ -105,6 +111,32 @@ class Lux::App < Thor
105
111
  end
106
112
  end
107
113
 
114
+ desc "rmimages", "Remove named Docker images (with optional pattern)"
115
+ method_option :match, type: :string, aliases: '-m', default: '*', desc: 'Matching files'
116
+ method_option :pattern, type: :string, aliases: '-p', default: nil, desc: 'Matching pattern (regex)'
117
+ method_option :confirm, type: :boolean, aliases: '-c', default: true, desc: 'Confirm removal'
118
+ def rmimages
119
+ if options.pattern
120
+ rx = Regexp.new(options.pattern)
121
+ matcher = lambda {|s| rx.match(s)}
122
+ else
123
+ matcher = lambda {|s| File.fnmatch?(options.match, s)}
124
+ end
125
+ imagelines = `docker images`.split("\n")[1..-1]
126
+ imagelines.each do |imageline|
127
+ imageinfo = imageline.split(/\s+/)
128
+ next if imageinfo[0] == '<none>'
129
+ imagename = imageinfo[0]+':'+imageinfo[1]
130
+ imagesize = imageinfo[-2]+' '+imageinfo[-1]
131
+ imageage = imageinfo[3..-3].join(' ')
132
+ next unless matcher.call(imagename)
133
+ if !options.confirm or (agree("Delete #{imagename} (#{imageage}, #{imagesize})? "){|q|q.echo=true})
134
+ `docker rmi #{imageinfo[2]}`
135
+ HighLine.say "Image <%= color('#{imagename}', RED)%> deleted"
136
+ end
137
+ end
138
+ end
139
+
108
140
  desc "clobber", "Destroy all containers (even if running!)"
109
141
  def clobber
110
142
  clean
@@ -167,7 +199,7 @@ class Lux::App < Thor
167
199
  end
168
200
 
169
201
  def die msg, rc = 1
170
- STDERR.puts msg
202
+ HighLine.say HighLine.color(msg, HighLine::RED)
171
203
  exit(rc)
172
204
  end
173
205
 
@@ -1,3 +1,3 @@
1
1
  module Lux
2
- VERSION = "0.3"
2
+ VERSION = "0.4"
3
3
  end
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.required_ruby_version = ">=2.0.0"
22
22
 
23
23
  spec.add_runtime_dependency "thor"
24
+ spec.add_runtime_dependency "highline"
24
25
  spec.add_runtime_dependency "bundler", "~> 1.9"
25
26
 
26
27
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lux
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Townsend
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-10 00:00:00.000000000 Z
11
+ date: 2015-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: highline
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement