1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# frozen_string_literal: true
require "cli/ui"
require "pathname"
require "thor"
require "yaml"
require "jive"
module Jive
module Cli
class App < Thor
package_name "jive"
def self.exit_on_failure?
true
end
def self.handle_no_command_error(name)
::Jive::Cli::App.start(["exec", name])
end
desc "docker SUBCOMMAND ...ARGS", "docker commands"
subcommand "docker", (Class.new(Thor) do
desc "build", "build the Dockerfile in the current directory"
def build
Docker.new.build(Pathname.pwd)
end
desc "launch", "launch a shell into a container"
def launch
Docker.new.launch(Pathname.pwd)
end
desc "size", "print the size of each image"
def size
Docker.new.size(Pathname.pwd)
end
end)
desc "git SUBCOMMAND ...ARGS", "git commands"
subcommand "git", (Class.new(Thor) do
desc "semantic", "Print help for semantic commit messages"
def semantic
say Git.new.semantic_help
end
method_option :host, type: :string, default: "github.com"
desc "clone <org>/<project>", "git clone to ~/src/github.com/<org>/<project>"
def clone(slug)
host = options[:host]
Jive.shell.run_safely { Git.new(Jive.shell).clone(slug, host: host) }
end
end)
desc "issue SUBCOMMAND ...ARGS", "issue things"
subcommand "issue", (Class.new(Thor) do
desc "list <type>", "List the issues"
def list(type = Issue.what_type?)
issues = Issue.for(type)
issue = Jive.prompt?(issues, display: ->(x) { x.file_name })
issue.edit
end
desc "create <type>", "Create a new issue"
def create(type = Issue.what_type?)
issue = Issue.create!(name: ask("Name:"), type: type)
issue.edit
end
end)
desc "cd <org>/<project>", "cd to ~/src/github.com/<org>/<project>"
def cd(slug)
Jive.shell.run_safely { Git.new(Jive.shell).cd(slug) }
end
desc "exec <command>", "run command from jive.yml"
def exec(command)
path = Pathname.pwd.join("jive.yml")
return shell.error("Error: jive.yml not found") unless path.exist?
Jive.shell.run_safely do
Jive.shell.execute(YAML.safe_load(path.read).dig("commands", command))
end
end
desc "bootstrap", "bootstrap the current project"
def bootstrap
Project
.new(Pathname.pwd)
.bootstrap(Jive.shell)
end
desc "pr", "pull request"
def pr
pr = PullRequest.new(repo: Repo.current)
pr.edit(ENV["EDITOR"])
end
desc "setup", "provide instructions to integrate into shell"
def setup
print "source #{::Jive.root.join("jive.sh")}"
end
end
end
end
|