Commit f2efd41
lib/jive/cli.rb
@@ -9,6 +9,48 @@ require "jive"
module Jive
module Cli
class App < Thor
+ package_name "jive"
+
+ desc "docker SUBCOMMAND ...ARGS", "docker commands"
+ subcommand "docker", (Class.new(Thor) do
+ desc "build", "build the Dockerfile in the current directory"
+ def build
+ Jive.shell.execute([
+ "docker",
+ "build",
+ "--network=host",
+ "-t", image_tag_for(Pathname.pwd),
+ "."
+ ], env: { "DOCKER_BUILDKIT" => "1" })
+ end
+
+ desc "launch", "launch a shell into a container"
+ def launch
+ Jive.shell.execute([
+ "docker",
+ "run",
+ "--network=host",
+ '--entrypoint=""',
+ "-it", image_tag_for(Pathname.pwd),
+ "/bin/bash -l"
+ ])
+ end
+
+ desc "size", "print the size of each image"
+ def size
+ Jive.shell.execute([
+ :docker, "image", "inspect", '--format="{{.Size}}"',
+ image_tag_for(Pathname.pwd)
+ ])
+ end
+
+ private
+
+ def image_tag_for(path)
+ "#{path.basename.to_s.downcase}:latest"
+ end
+ end)
+
def self.exit_on_failure?
true
end
@@ -19,12 +61,12 @@ module Jive
desc "cd <org>/<project>", "cd to ~/src/github.com/<org>/<project>"
def cd(slug)
- runner.run_safely { Git.new(runner).cd(slug) }
+ Jive.shell.run_safely { Git.new(Jive.shell).cd(slug) }
end
desc "clone <org>/<project>", "git clone to ~/src/github.com/<org>/<project>"
def clone(slug)
- runner.run_safely { Git.new(runner).clone(slug) }
+ Jive.shell.run_safely { Git.new(Jive.shell).clone(slug) }
end
desc "exec <command>", "run command from jive.yml"
@@ -32,8 +74,8 @@ module Jive
path = Pathname.pwd.join("jive.yml")
return shell.error("Error: jive.yml not found") unless path.exist?
- runner.run_safely do
- runner.execute(YAML.safe_load(path.read).dig("commands", command))
+ Jive.shell.run_safely do
+ Jive.shell.execute(YAML.safe_load(path.read).dig("commands", command))
end
end
@@ -41,22 +83,12 @@ module Jive
def bootstrap
Project
.new(Pathname.pwd)
- .bootstrap(runner)
+ .bootstrap(Jive.shell)
end
desc "setup", "provide instructions to integrate into shell"
def setup
- say <<~MESSAGE
- Include the following in your ~/.bash_profile
-
- source #{::Jive.root.join("jive.sh")}
- MESSAGE
- end
-
- private
-
- def runner
- @runner ||= ::Jive::Shell.new
+ print "source #{::Jive.root.join("jive.sh")}"
end
end
end
lib/jive.rb
@@ -21,4 +21,8 @@ module Jive
def self.run(tasks)
Jive::BatchRunner.new.run(tasks)
end
+
+ def self.shell
+ @shell ||= ::Jive::Shell.new
+ end
end