Sha256: b6dc54f9e4642c1e59bac870681747753e7187e19cb32ea71ce4f6245f3a6935

Contents?: true

Size: 1.6 KB

Versions: 4

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

require 'thor'

module KStarter
  # Handle the application command line parsing
  # and the dispatch to various command objects
  #
  # @api public
  class CLI < Thor
    # Error raised by this runner
    Error = Class.new(StandardError)

    desc 'version', 'k_starter version'
    def version
      require_relative 'version'
      puts "v#{KStarter::VERSION}"
    end
    map %w[--version -v] => :version

    #
    # config
    #
    # desc 'config KEYVALUE', 'Config description'
    # method_option :help, aliases: '-h',
    #                      type: :boolean,
    #                      desc: 'Display usage information'
    # def config(key, value)
    #   if options[:help]
    #     invoke :help, ['config']
    #   else
    #     KStarter::Commands::Configuration::Menu.new(key, value, options).execute
    #   end
    # end

    #
    # configuration
    #
    desc 'configuration SUBCOMMAND', 'Manage configuration'
    method_option :help, aliases: '-h',
                         type: :boolean,
                         desc: 'Display usage information'
    def configuration(subcommand = :menu)
      if options[:help]
        invoke :help, ['configuration']
      else
        KStarter::Commands::ConfigurationMenu.new(subcommand, options).execute
      end
    end

    #
    # project
    #
    desc 'project SUBCOMMAND', 'Create or edit project settings or generate new project'
    def project(subcommand = :menu)
      if options[:help]
        invoke :help, ['project']
      else
        KStarter::Commands::ProjectMenu.new(subcommand, options).execute
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
k_starter-0.1.4 lib/k_starter/cli.rb
k_starter-0.1.3 lib/k_starter/cli.rb
k_starter-0.1.2 lib/k_starter/cli.rb
k_starter-0.1.1 lib/k_starter/cli.rb