Class: Walkman::CLI
- Inherits:
-
Thor
- Object
- Thor
- Walkman::CLI
- Defined in:
- lib/walkman/cli.rb
Instance Method Summary collapse
- #like ⇒ Object
- #next(count = 1) ⇒ Object
- #now_playing ⇒ Object
- #play ⇒ Object
- #play_artist(*artist) ⇒ Object
- #play_artist_radio(*artist) ⇒ Object
- #shutdown ⇒ Object
- #skip(count = 1) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #up_next ⇒ Object
Instance Method Details
#like ⇒ Object
95 96 97 98 |
# File 'lib/walkman/cli.rb', line 95 def like response = server.run_command(:like) puts response unless response.empty? end |
#next(count = 1) ⇒ Object
57 58 59 60 |
# File 'lib/walkman/cli.rb', line 57 def next(count = 1) response = server.run_command(:next, count: count.to_i) puts response unless response.empty? end |
#now_playing ⇒ Object
69 70 71 72 |
# File 'lib/walkman/cli.rb', line 69 def response = server.run_command(:now_playing) puts response unless response.empty? end |
#play ⇒ Object
45 46 47 48 |
# File 'lib/walkman/cli.rb', line 45 def play response = server.run_command(:play) puts response unless response.empty? end |
#play_artist(*artist) ⇒ Object
81 82 83 84 85 |
# File 'lib/walkman/cli.rb', line 81 def play_artist(*artist) artist = artist.join(" ") response = server.run_command(:artist, artist: artist) puts response unless response.empty? end |
#play_artist_radio(*artist) ⇒ Object
88 89 90 91 92 |
# File 'lib/walkman/cli.rb', line 88 def play_artist_radio(*artist) artist = artist.join(" ") response = server.run_command(:artist_radio, artist: artist) puts response unless response.empty? end |
#shutdown ⇒ Object
35 36 37 38 39 40 |
# File 'lib/walkman/cli.rb', line 35 def shutdown response = server.run_command(:player_stop) puts response unless response.empty? server.stop_server end |
#skip(count = 1) ⇒ Object
63 64 65 66 |
# File 'lib/walkman/cli.rb', line 63 def skip(count = 1) response = server.run_command(:skip, count: count.to_i) puts response unless response.empty? end |
#start ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/walkman/cli.rb', line 11 def start if [:daemon] Process.daemon else puts "Starting walkman server" puts "Run `walkman start -d` for daemon" puts "Ctrl-C to shutdown" trap("INT") do # calling this in a thread to get proper logging Thread.new do shutdown end.join end end Walkman.logger.info("starting server") Walkman::Commands::Player.start DRb.start_service(Walkman.config.drb_uri, self) DRb.thread.join end |
#stop ⇒ Object
51 52 53 54 |
# File 'lib/walkman/cli.rb', line 51 def stop response = server.run_command(:stop) puts response unless response.empty? end |
#up_next ⇒ Object
75 76 77 78 |
# File 'lib/walkman/cli.rb', line 75 def up_next response = server.run_command(:up_next) puts response unless response.empty? end |