Class: Rupeepeethree::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/rupeepeethree.rb

Class Method Summary collapse

Class Method Details

.run(args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rupeepeethree.rb', line 8

def self.run(args)
  p = Optimist::Parser.new do
    version "RP3 version #{VERSION} by Tony Miller"
    banner <<-EOS
  ░█▀▄░█▀█░▀▀█
  ░█▀▄░█▀▀░░▀▄
  ░▀░▀░▀░░░▀▀░
  ┣¨キ┣¨キ
  You thought your mp3s were cool. Turns out you were wrong. Your mp3s have no tags. You must tag them!
    EOS
    opt :title, "title", type: String, short: 't'
    opt :artist, "artist", type: String, short: 'a'
    opt :year, "track year", type: String, short: 'Y'
    opt :track, "track number", type: String, short: 'n'
    opt :album, "album title", type: String, short: 'A'
    opt :picture, "artwork", type: String, short: 'p'
    opt :clear, "clear all tags!"
  end

  opts = Optimist::with_standard_exception_handling p do
    raise Optimist::HelpNeeded if ARGV.empty? # show help screen
    p.parse ARGV
  end

  mp3s = ARGV
  if mp3s.empty?
    abort("no mp3 specified...")
  end
  mp3s.each do |mp3|
    if opts[:clear]
      Tagger.clear(mp3)
    else
      Tagger.tag(mp3,opts)
      puts Tagger.print_tags(mp3)
    end
  end
end