cirun 0.1.19 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e66eb181e998f5d288d56e9d42c572fb565e7a0488ccb60a52e7282d307d82e
4
- data.tar.gz: 8f8042b72c90bdd1077266ef7f4aaace0074dc505ee1351c8a9c733a66c50c72
3
+ metadata.gz: f1f419a6ffa683a9f8d781b09c3ba93a2db464e6f944f90337dd7bc0b0605cdc
4
+ data.tar.gz: 2d1320c38681fe7be4a533feec5875b2d9593b6e1f55f17197724d11ee2be5b6
5
5
  SHA512:
6
- metadata.gz: 48af0a5ec50138ada057f77b6b940d45d400873e4b629a18abbfe0fae886c5486c3736d69619d2000841e7699f979b629a48a9ffdf219cc9ef79274b0b50557e
7
- data.tar.gz: 3c5c980bdb1d1a0c38ef4b66eae50b9151553a239de9ee70447d22d04b34448dff51ea3ea5fa2c9c4b0d206dd34f9ec22dc9fd0bdf0881dd91a442b28c60e3c8
6
+ metadata.gz: 9d8745fdb29e9c1543e5ad7ad4442546f3917a135661ac278dc13744c18a582e1c414cdba8c55b07a0347aa6dd133ec878b9dae917487c1e1ca4db104b7df29c
7
+ data.tar.gz: b31959617b0627ea5e8b3b3911fc1f3c75af2684bc85b72bf6efa1aa58c03ec797eb466fd7ef41c16e3e3842519bf5237148bee211b342f0d8235c4d7c2b04d7
data/lib/cirun/cli.rb CHANGED
@@ -13,6 +13,7 @@ module Cirun
13
13
  @options.ruby = ''
14
14
  @options.plugin = ''
15
15
  @options.dependent = ''
16
+ @options.print = false
16
17
  end
17
18
 
18
19
  def parse
@@ -33,6 +34,19 @@ module Cirun
33
34
  opts.on('-e', '--dependent DEPENDENT', "Specify plugin dependency") do |dependent|
34
35
  @options.dependent = dependent
35
36
  end
37
+ opts.on(
38
+ '-i',
39
+ '--interactive',
40
+ 'Instead of executing docker for you this will just print',
41
+ ' required command string to the standard output.',
42
+ ' This is useful when you want to run interactive',
43
+ ' debug session. Docker CLI is very hard to trick',
44
+ ' so with this option you can just backtick output',
45
+ ' like: `cirun -d mysql -m 2.3 -r 1.9.3-p551 -i`'
46
+ ) do
47
+ @options.print = true
48
+ end
49
+
36
50
  end.parse!
37
51
 
38
52
  validate_options || abort_due_to_lack_of_options
data/lib/cirun/runner.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'open3'
2
- require 'tty-command'
3
2
 
4
3
  module Cirun
5
4
  class Runner
@@ -8,33 +7,32 @@ module Cirun
8
7
  end
9
8
 
10
9
  def update_image
11
- puts "Pulling redmineup/#{@opts.plugin}, please wait"
10
+ puts "Pulling redmineup/#{@opts.plugin}, please wait" unless @opts.print
12
11
  cmd = "docker pull redmineup/#{@opts.plugin}"
13
- execute(cmd)
12
+ execute(cmd, @opts.print)
14
13
  end
15
14
 
16
15
  def run
17
16
  update_image
18
17
  ruby_short = @opts.ruby.split('-').first
19
- cmd = "docker run -it --env RUBY_VERSION=ruby-#{ruby_short} --env DB=#{@opts.database} --env REDMINE=redmine-#{@opts.redmine} --env PLUGIN=#{@opts.plugin} --env DEPENDENT=#{@opts.dependent} --mount type=bind,source=#{`pwd`.chomp},target=/var/www/ruby-#{ruby_short}/#{@opts.database}/redmine-#{@opts.redmine}/plugins/#{@opts.plugin} redmineup/#{@opts.plugin} /root/run_local.sh"
20
- execute_tty(cmd)
18
+ cmd = "docker run -#{@opts.print ? 'i' : ''}t --env RUBY_VERSION=ruby-#{ruby_short} --env DB=#{@opts.database} --env REDMINE=redmine-#{@opts.redmine} --env PLUGIN=#{@opts.plugin} --env DEPENDENT=#{@opts.dependent} --mount type=bind,source=#{`pwd`.chomp},target=/var/www/ruby-#{ruby_short}/#{@opts.database}/redmine-#{@opts.redmine}/plugins/#{@opts.plugin} redmineup/#{@opts.plugin} /root/run_local.sh"
19
+ @opts.print ? print(cmd) : execute(cmd)
21
20
  end
22
21
 
23
22
  private
24
23
 
25
- def execute(cmd)
26
- puts "Running:\n#{cmd}"
24
+ def execute(cmd, silently = false)
25
+ puts "Running:\n#{cmd}" unless silently
27
26
  Open3.popen3(cmd) do |stdin, stdout, stderr|
28
27
  while (line = stdout.gets)
29
- puts line
28
+ puts line unless silently
30
29
  end
31
- puts stderr.read
30
+ puts stderr.read unless silently
32
31
  end
33
32
  end
34
33
 
35
- def execute_tty(command)
36
- cmd = TTY::Command.new
37
- cmd.run(command)
34
+ def print(command)
35
+ puts command
38
36
  end
39
37
  end
40
38
  end
data/lib/cirun/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cirun
2
- VERSION = '0.1.19'.freeze
2
+ VERSION = '0.1.20'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cirun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.19
4
+ version: 0.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Malyshev