Sha256: f597daa010f202ac53259c666b3498e4fb9fd5f86dada37b15bcf13bf006a289

Contents?: true

Size: 898 Bytes

Versions: 1

Compression:

Stored size: 898 Bytes

Contents

require "thor"

module Boty
  class CLI < Thor
    include Thor::Actions
    class_option :verbose, type: :boolean

    attr_reader :bot_name, :company, :api_key

    source_root File.expand_path("../../../template", __FILE__)

    desc "new [BOT_NAME]",
         "Creates a BOT_NAME dir with your new bot structure."
    def new(bot_name)
      @bot_name = bot_name
      acquire_bot_info bot_name
      directory "project", bot_name, verbose: verbose
      inside bot_name do
        # for some reason the example .rspec isn't been copied
        create_file ".rspec", "--require=spec_helper"
        run "chmod +x bot"
      end
    end

    private

    def verbose
      options[:verbose]
    end

    def acquire_bot_info(bot_name)
      @company = ask("What is your Slack company name?") || "acme"
      @api_key = ask("What is the #{@bot_name} api key?") || "omg-lol-bbq"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
boty-0.0.4 lib/boty/cli.rb