#!/usr/bin/env node
'use strict';

var vorpal = require('vorpal')();
var itunesRemote = require('./');

vorpal
	.delimiter('iTunes:')
	.show();

vorpal.find('exit').description('Exit itunes-remote.');

vorpal
	.command('play', 'Start playing the current selection')
	.action(function (args, callback) {
		var self = this;
		self.log('Hold on …');
		itunesRemote('play', function (response) {
			self.log(response);
			callback();
		});
	});

vorpal
	.command('stop', 'Stop playing the current selection')
	.action(function (args, callback) {
		var self = this;
		self.log('Hold on …');
		itunesRemote('stop', function (response) {
			self.log(response);
			callback();
		});
	});

vorpal
	.command('pause', 'Pause playing the current selection')
	.action(function (args, callback) {
		var self = this;
		self.log('Hold on …');
		itunesRemote('pause', function (response) {
			self.log(response);
			callback();
		});
	});

vorpal
	.command('search <searchterm>', 'Fuzzy search album, artists and songs.')
	.option('-d, --dont-play', 'Prevent playing the search result.')
	.action(function (args, callback) {
		var self = this;
		self.log('Hold on …');
		itunesRemote('search', function (response) {
			self.log(response);
			callback();
		}, args);
	});

vorpal.parse(process.argv);

@@ -1126,77 +1126,324 @@
 ;%0A%09%09
-self.log('Hold on %E2%80%A6');%0A%09%09itunesRemote('search', function (response) %7B
+var frames = %5B' ', ' ','.',  '..', '...', '....', '.....'%5D;%0A%09%09var i = 0;%0A%09%09var waiting = setInterval(function() %7B%0A%09%09%09var frame = frames%5Bi = ++i %25 frames.length%5D;%0A%09%09%09vorpal.ui.redraw('Hold on. ' + frame);%0A%09%09%7D, 250);%0A%09%09itunesRemote('search', function (response) %7B%0A%09%09%09clearInterval(waiting);%0A%09%09%09vorpal.ui.redraw.done();
 %0A%09%09%09

Add waiting indicator