Module: Nehm

Defined in:
lib/nehm.rb,
lib/nehm/os.rb,
lib/nehm/ui.rb,
lib/nehm/cfg.rb,
lib/nehm/menu.rb,
lib/nehm/track.rb,
lib/nehm/client.rb,
lib/nehm/artwork.rb,
lib/nehm/command.rb,
lib/nehm/version.rb,
lib/nehm/playlist.rb,
lib/nehm/applescript.rb,
lib/nehm/http_client.rb,
lib/nehm/path_manager.rb,
lib/nehm/user_manager.rb,
lib/nehm/option_parser.rb,
lib/nehm/track_manager.rb,
lib/nehm/command_manager.rb,
lib/nehm/playlist_manager.rb,
lib/nehm/commands/dl_command.rb,
lib/nehm/tracks_view_command.rb,
lib/nehm/commands/get_command.rb,
lib/nehm/commands/help_command.rb,
lib/nehm/commands/list_command.rb,
lib/nehm/commands/search_command.rb,
lib/nehm/commands/version_command.rb,
lib/nehm/commands/configure_command.rb

Defined Under Namespace

Modules: AppleScript, Cfg, Client, CommandManager, OS, PathManager, PlaylistManager, UI, UserManager Classes: Artwork, Command, ConfigureCommand, DlCommand, GetCommand, HTTPClient, HelpCommand, ListCommand, NehmExit, OptionParser, Playlist, SearchCommand, Track, TrackManager, TracksViewCommand, VersionCommand

Constant Summary collapse

HELP =
<<-EOF
#{'nehm'.green} is a console tool, which downloads, sets IDv3 tags (and adds to your iTunes library) your SoundCloud posts or likes in convenient way

#{'Available nehm commands:'.yellow}
  #{'get'.green}        Download, set tags and add to your iTunes library last post(s) or like(s) from your profile
  #{'dl'.green}         Download and set tags last post(s) or like(s) from your profile
  #{'configure'.green}  Configure application
  #{'help'.green}       Show help for specified command
  #{'list'.green}       Get list of likes or posts from your account and download selected
  #{'search'.green}     Search tracks, print them nicely and download selected tracks
  #{'version'.green}    Show version of installed nehm

See #{'nehm help COMMAND'.yellow} to read about a specific command

Commands and arguments (but NOT options) may be abbreviated, so long as they are unambiguous
e.g. #{'nehm g l'.magenta} is short for #{'nehm get like'.magenta}
EOF
VERSION =
'2.2.2'.freeze

Class Method Summary collapse

Class Method Details

.initObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/nehm.rb', line 54

def init
  UI.say 'Hello!'.green
  UI.say 'Before using the nehm, you should set it up:'
  Cfg.create unless Cfg.exist?

  PathManager.set_dl_path
  UI.newline

  UserManager.set_uid
  UI.newline

  if OS.mac?
    PlaylistManager.set_playlist
    UI.newline
  end

  UI.success 'Now you can use nehm!'
  UI.newline

  UI.sleep
end

.initialized?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/nehm.rb', line 76

def initialized?
  Cfg.exist?
end

.start(args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nehm.rb', line 17

def self.start(args)
  begin
    init unless initialized?

    if args.empty?
      UI.say HELP
      UI.term
    end

    CommandManager.run(args)
  rescue StandardError, Timeout::Error => ex
    Nehm::UI.term "While executing nehm ... (#{ex.class})\n    #{ex}"
  rescue Interrupt
  rescue NehmExit
  end
end