Commit 9ec0b9a
lib/jive/cli.rb
@@ -41,26 +41,14 @@ module Jive
subcommand "git", (Class.new(Thor) do
desc "semantic", "Print help for semantic commit messages"
def semantic
- say <<~MESSAGE
- Format: <type>(<scope>): <subject>
-
- <scope> is optional
-
- feat: add hat wobble
- ^--^ ^------------^
- | |
- | +-> Summary in present tense.
- |
- +-------> Type: chore, docs, feat, fix, refactor, style, or test.
+ say Git.new.semantic_help
+ end
- chore: updating grunt tasks etc; no production code change
- docs: changes to the documentation
- feat: new feature for the user, not a new feature for build script
- fix: bug fix for the user, not a fix to a build script
- refactor: refactoring production code, eg. renaming a variable
- style: formatting, missing semi colons, etc; no production code change
- test: adding missing tests, refactoring tests; no production code change
- MESSAGE
+ 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)
@@ -69,11 +57,6 @@ module Jive
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)
- Jive.shell.run_safely { Git.new(Jive.shell).clone(slug) }
- end
-
desc "exec <command>", "run command from jive.yml"
def exec(command)
path = Pathname.pwd.join("jive.yml")
lib/jive/git.rb
@@ -4,23 +4,23 @@ module Jive
class Git
attr_reader :shell
- def initialize(shell)
+ def initialize(shell = ::Jive.shell)
@shell = shell
end
- def clone(slug)
- dir = target_dir_for(slug)
+ def clone(slug, host: "github.com")
+ dir = target_dir_for(slug, host: host)
unless dir.exist?
shell.run_each([
[:mkdir, "-p", dir.parent.to_s],
- [:git, "clone", "git@github.com:#{slug}.git", dir]
+ [:git, "clone", "git@#{host}:#{slug}.git", dir]
])
end
cd(slug)
end
- def cd(slug)
- dir = target_dir_for(slug)
+ def cd(slug, host: "github.com")
+ dir = target_dir_for(slug, host: host)
if dir.exist?
shell.after_run([
["cd", dir],
@@ -31,10 +31,33 @@ module Jive
end
end
+ def semantic_help
+ <<~MESSAGE
+ Format: <type>(<scope>): <subject>
+
+ <scope> is optional
+
+ feat: add hat wobble
+ ^--^ ^------------^
+ | |
+ | +-> Summary in present tense.
+ |
+ +-------> Type: chore, docs, feat, fix, refactor, style, or test.
+
+ chore: updating grunt tasks etc; no production code change
+ docs: changes to the documentation
+ feat: new feature for the user, not a new feature for build script
+ fix: bug fix for the user, not a fix to a build script
+ refactor: refactoring production code, eg. renaming a variable
+ style: formatting, missing semi colons, etc; no production code change
+ test: adding missing tests, refactoring tests; no production code change
+ MESSAGE
+ end
+
private
- def target_dir_for(slug)
- Pathname.new(Dir.home).join("src/github.com/#{slug}")
+ def target_dir_for(slug, host:)
+ Pathname.new(Dir.home).join("src/#{host}/#{slug}")
end
end
end