class Lyricsender::CLI::Commands::Setup
Public Instance Methods
call(*)
click to toggle source
# File bin/lyricsender, line 34 def call(*) ### warning - This part is duplicated and I cannot figure out how to fix it # Supports https://no-color.org env_no_color = false if ENV['NO_COLOR'] pastel = Pastel.new(enabled: env_no_color) config = TTY::Config.new prompt = TTY::Prompt.new(enable_color: env_no_color) config.filename = "lyricsender" config.extname = ".toml" config_append_path = "#{Dir.home}/.config" config.append_path config_append_path unless OS.mac? puts print pastel.bold.red "(!) Note: only macOS is supported" puts pastel.red " (this uses iMessage and AppleScript)." if prompt.yes? "Continue anyway?" nil else exit 1 end end ### end duplicated part if !config.exist? puts puts pastel.bold "Hi, welcome to lyricsender!" puts "You'll need an access token from Genius to use this." if prompt.yes? "Open genius.com/api-clients to create one?" Launchy.open "http://genius.com/api-clients" end set_token = prompt.ask("Please paste your #{pastel.bold "client access token"} here and press enter:", convert: :str, required: true) config.set(:token, value: set_token) puts "Perfect; writing to `#{config_append_path}/#{config.filename}#{config.extname}`…" config.write print pastel.bold.green "Setup complete!" puts pastel.green " You can now run `lyricsender send` to send something." else puts pastel.red "Looks like you're already set up!" puts pastel.dim "(Your config file is located at #{config_append_path}/#{config.filename}#{config.extname})" exit 1 end end