Sha256: a41a666cf08ae82a56e4f3590b1d256ec9329a204c2f960ada7ea0d43bdc88c1

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

# 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 <org>/<project>", "cd to ~/src/github.com/<org>/<project>"
      def cd(slug)
        runner.run_safely { Git.new(runner).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) }
      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?

        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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jive-0.2.3 lib/jive/cli.rb