Sha256: afc688166619dae757ca042495259c3732849b0f413d2ee31b680765596d454c

Contents?: true

Size: 1.36 KB

Versions: 14

Compression:

Stored size: 1.36 KB

Contents

#!/usr/bin/env ruby

require 'gli'
require 'slack-ruby-client'

include GLI::App

program_desc 'Slack client.'

default_command :help

switch [:d, :debug], desc: 'Enable debug-level logging.', default_value: false
flag [:t, 'slack-api-token'], desc: 'Slack API token.', default_value: ENV['SLACK_API_TOKEN']
flag ['vcr-cassette-name'], desc: 'Offline VCR cassette.'

pre do |global_options, _command, options, _args|
  # global Slack configuration
  Slack.config.token = global_options['slack-api-token']
  help_now! 'Set Slack API token via --slack-api-token or SLACK_API_TOKEN.' unless Slack.config.token && !Slack.config.token.empty?

  if global_options['debug']
    require 'logger'
    logger = Logger.new(STDOUT)
    logger.level = Logger::DEBUG
    Slack::Web::Client.config.logger = logger
  end

  $client = Slack::Web::Client.new

  # Offline VCR cassette
  if global_options['vcr-cassette-name']
    require 'webmock'
    WebMock.enable!
    require 'vcr'
    VCR.configure do |config|
      config.cassette_library_dir = 'spec/fixtures/slack'
      config.hook_into :webmock
      config.default_cassette_options = { record: :new_episodes }
    end
    VCR.insert_cassette global_options['vcr-cassette-name']
  end

  # remove any nil values from options
  options.select! { |_k, v| v }

  true
end

$LOAD_PATH.push File.expand_path('..', __FILE__)
require 'commands'

exit run(ARGV)

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
slack-ruby-client-0.10.0 bin/slack
slack-ruby-client-0.9.1 bin/slack
slack-ruby-client-0.9.0 bin/slack
slack-ruby-client-0.8.1 bin/slack
slack-ruby-client-0.8.0 bin/slack
slack-ruby-client-0.7.9 bin/slack
slack-ruby-client-0.7.8 bin/slack
slack-ruby-client-0.7.7 bin/slack
slack-ruby-client-0.7.6 bin/slack
slack-ruby-client-0.7.5 bin/slack
slack-ruby-client-0.7.4 bin/slack
slack-ruby-client-0.7.3 bin/slack
slack-ruby-client-0.7.2 bin/slack
slack-ruby-client-0.7.1 bin/slack