Sha256: 0e7f531b5b9624970f0d672f9b11ddbc1418133a467de780cab0808f08ade6a9

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require 'thor'

module Sumcli
  # 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', 'sumcli version'
    def version
      require_relative 'version'
      puts "v#{Sumcli::VERSION}"
    end
    map %w(--version -v) => :version

    desc 'start', 'Command description...'
    method_option :help, aliases: '-h', type: :boolean,
                         desc: 'Display usage information'
    def start(*)
      if options[:help]
        invoke :help, ['start']
      else
        require_relative 'commands/start'
        Sumcli::Commands::Start.new(options).execute
      end
    end

    require_relative 'commands/new'
    require_relative 'commands/add'
    register Sumcli::Commands::Add, 'add', 'add [SUBCOMMAND]', 'Adds services to your project'
    
    desc 'new NAME', 'Creates a new application'
    method_option :help, aliases: '-h', type: :boolean,
                         desc: 'Display usage information'
    def new(name)
      if options[:help]
        invoke :help, ['new']
      else
        Sumcli::Commands::New.new(name, options).execute
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sumcli-0.6.0 lib/sumcli/cli.rb