# frozen_string_literal: true require "pathname" require "thor" require "yaml" require "jive" module Jive module Cli class App < Thor def self.exit_on_failure? true end desc "cd /", "cd to ~/src/github.com//" def cd(slug) runner.run_safely { Git.new(runner).cd(slug) } end desc "clone /", "git clone to ~/src/github.com//" def clone(slug) runner.run_safely { Git.new(runner).clone(slug) } end desc "exec ", "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? runner.run_safely do runner.execute(YAML.safe_load(path.read).dig("commands", command)) end 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 end end end end