Module: GrooveDl::CLI

Defined in:
lib/groove-dl/cli.rb

Overview

CLI module

Constant Summary collapse

SLOP_OPTIONS =

Hash containing the default Slop options.

Returns:

  • (Hash)
{
  strict: true,
  help: true,
  banner: 'Usage: groove-dl [COMMAND] [OPTIONS]'
}

Class Method Summary collapse

Class Method Details

.default_optionsSlop

Returns:

  • (Slop)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/groove-dl/cli.rb', line 26

def self.default_options
  Slop.new(SLOP_OPTIONS.dup) do
    separator "\nOptions:\n"

    on :v, :version, 'Shows the current version' do
      puts CLI.version_information
    end

    on :p=, :playlist=, 'Playlist', as: Integer
    on :s=, :song=, 'Song', as: Integer
    on :o=, :output=, 'Output directory', as: String

    run do |opts|
      next if opts[:v]

      client = Grooveshark::Client.new
      d = Downloader.new(client, opts)
      d.playlist(opts[:p]) if opts[:p]
      d.song(opts[:s]) if opts[:s]
    end
  end
end

.optionsSlop

Returns:

  • (Slop)


19
20
21
# File 'lib/groove-dl/cli.rb', line 19

def self.options
  @options ||= default_options
end

.version_informationString

Returns a String containing some platform/version related information.

Returns:

  • (String)


54
55
56
# File 'lib/groove-dl/cli.rb', line 54

def self.version_information
  "Groove-dl v#{VERSION} on #{RUBY_DESCRIPTION}"
end