Sha256: 770689a9a14b9ae4233471a21812bb18d8108cd3a5768153521a2fd5196c3678

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true

require "thor"

module Boilercode
  # 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", "boilercode version"
    def version
      require_relative "version"
      puts "v#{Boilercode::VERSION}"
    end
    map %w[--version -v] => :version

    require_relative "commands/drive"
    register Boilercode::Commands::Drive, "drive", "drive [SUBCOMMAND]", "Manage your file uploads"

    require_relative "commands/bookmarks"
    register Boilercode::Commands::Bookmarks, "bookmarks", "bookmarks [SUBCOMMAND]", "Manage your bookmarks"

    require_relative "commands/snippets"
    register Boilercode::Commands::Snippets, "snippets", "snippets [SUBCOMMAND]", "Manage your snippets"

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

    desc "login", "Authenticate with Boilercode.io"
    method_option :help, aliases: "-h", type: :boolean,
      desc: "Display usage information"
    def login(*)
      if options[:help]
        invoke :help, ["login"]
      else
        require_relative "commands/login"
        Boilercode::Commands::Login.new.execute
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
boilercode-0.1.0 lib/boilercode/cli.rb