Sha256: c4e8be57cd94a5e4a333a3a1e621bcffae1535ea96c3b866cea5fdbd37095159

Contents?: true

Size: 1.04 KB

Versions: 35

Compression:

Stored size: 1.04 KB

Contents

# description: Setup application commands.
require "optparse"
require "discorb/utils/colored_puts"

ARGV.delete_at 0

options = {
  guilds: nil,
}

opt = OptionParser.new <<~BANNER
                         This command will setup application commands.

                         Usage: discorb setup [options] [script]

                                   script                     The script to setup.
                       BANNER
opt.on("-g", "--guild ID", Array, "The guild ID to setup, use comma for setup commands in multiple guilds, or `global` for setup global commands.") { |v| options[:guilds] = v }
opt.parse!(ARGV)

script = ARGV[0]
script ||= "main.rb"
ENV["DISCORB_CLI_FLAG"] = "setup"

if options[:guilds] == ["global"]
  ENV["DISCORB_SETUP_GUILDS"] = "global"
elsif options[:guilds]
  ENV["DISCORB_SETUP_GUILDS"] = options[:guilds].join(",")
else
  ENV["DISCORB_SETUP_GUILDS"] = nil
end

begin
  load script
rescue LoadError
  eputs "Could not load script: \e[31m#{script}\e[m"
else
  sputs "Successfully set up commands for \e[32m#{script}\e[m."
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
discorb-0.9.5 lib/discorb/exe/setup.rb
discorb-0.9.4 lib/discorb/exe/setup.rb
discorb-0.9.3 lib/discorb/exe/setup.rb
discorb-0.9.1 lib/discorb/exe/setup.rb
discorb-0.9.0 lib/discorb/exe/setup.rb
discorb-0.8.2 lib/discorb/exe/setup.rb
discorb-0.8.1 lib/discorb/exe/setup.rb
discorb-0.8.0 lib/discorb/exe/setup.rb
discorb-0.7.6 lib/discorb/exe/setup.rb
discorb-0.7.3 lib/discorb/exe/setup.rb
discorb-0.7.2 lib/discorb/exe/setup.rb
discorb-0.7.1 lib/discorb/exe/setup.rb
discorb-0.7.0 lib/discorb/exe/setup.rb
discorb-0.6.1 lib/discorb/exe/setup.rb
discorb-0.6.0 lib/discorb/exe/setup.rb