Skip to content

Commit

Permalink
[command] for running container easy
Browse files Browse the repository at this point in the history
  • Loading branch information
tapalilov committed Nov 15, 2017
1 parent cc3cb63 commit ba1a1ff
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
30 changes: 30 additions & 0 deletions bin/gaku
@@ -0,0 +1,30 @@
#!/usr/bin/env ruby
require 'thor'
require_relative '../lib/gaku/container'

class GakuCLI < Thor
desc 'container', 'handle container for gaku'
argument :command, default: 'start', description: 'action to execute'
def container
return unless check
Gaku::Container.new(command).execute
end

desc 'version', "Prints the version of the installed WSlave"
def version()
require 'rubygems'
spec = Gem::Specification::load("#{__dir__}/../gaku.gemspec")
puts spec.version
end

private

def check
return true if File.exist?("Dockerfile") && File.exist?("docker-compose.yml")
puts "This does not appear to be the root of gaku."
false
end

end

GakuCLI.start(ARGV)
32 changes: 32 additions & 0 deletions lib/gaku/container.rb
@@ -0,0 +1,32 @@
module Gaku
class Container
attr_accessor :command

def initialize(command)
require 'pry';binding.pry
@command = command
end

def execute
system(resolve_command)
end

private

def resolve_command
case command
when 'start'
'docker-compose up'
when 'console'
'docker-compose exec web bundle exec rails console'
when 'shell'
'docker-compose exec web bundle exec /bin/bash'
when 'sample'
'docker-compose exec web bundle exec rake db:sample'
when 'detach'
'docker-compose up -d'
end
end

end
end

0 comments on commit ba1a1ff

Please sign in to comment.