Sha256: 200fd2d8287d751c17b733b4b869d12b83b5396fb8cace7577e3492ce3eb3116

Contents?: true

Size: 975 Bytes

Versions: 1

Compression:

Stored size: 975 Bytes

Contents

# frozen_string_literals: true

require "thor"
require "jobshop/cli/application"
require "jobshop/cli/canary"
require "jobshop/cli/app_generator"

module Jobshop
  module CLI
    class << self
      def start(argv = ARGV)
        if [ "-v", "--version" ].include?(argv[0])
          require "jobshop/version"

          puts "Jobshop #{Jobshop.gem_version}"
          exit 0
        end

        if application?
          Jobshop::CLI::Application.start(argv)
        elsif canary?
          Jobshop::CLI::Canary.start(argv)
        else
          Jobshop::CLI::AppGenerator.start(argv)
        end
      end

      def application?
        has_executable? && !has_gemspec?
      end

      def canary?
        has_executable? && has_gemspec?
      end

      private def has_executable?
        @has_executable ||= File.file?("bin/jobshop")
      end

      private def has_gemspec?
        @jobshop_development ||= File.file?("jobshop.gemspec")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jobshop-0.0.167 lib/jobshop/cli.rb