<commit_before>#!/usr/bin/env node
/*
 * spotify-cli
 * https://github.com/shidel-dev/spotify-cli
 *
 * Copyright (c) 2014 shidel.dev
 * Licensed under the MIT license.
 */

var exec = require('child_process').exec;
var spotifyCli = require('commander');

function osa(osaFunction) {
  var args = Array.prototype.slice.call(arguments, 1, arguments.length - 1);
  var done = arguments[arguments.length - 1];
  var jsonArgs = args.map(JSON.stringify);
  var functionCallString = 'JSON.stringify((' + osaFunction.toString() + ')(' + jsonArgs.join(',') + '));';
  var escapedCall = functionCallString.replace(/^\s+/g, ' ').replace(/\n/g, '').replace(/'/g, "'\\''");
  var executeString = "osascript -l JavaScript -e '" + escapedCall + "'";
  exec(executeString);
};

spotifyCli.version('0.1.0');

spotifyCli
  .command('play')
  .description('Start playback')
  .action(function(){
    osa(spotifyCli.play)
  });

spotifyCli
  .command('pause')
  .description('Pause playback')
  .action(function(){
    osa(spotifyCli.pause)
  });

spotifyCli
  .command('open')
  .description('Pause playback')
  .action(function(){
    osa(spotifyCli.open)
  });

spotifyCli
  .command('quit')
  .description('Pause playback')
  .action(function(){
    osa(spotifyCli.quit)
  });


spotifyCli.play = function() {
  Application('Spotify').play();
};

spotifyCli.pause = function() {
  Application('Spotify').pause();
};

spotifyCli.open = function() {
  Application('Spotify').activate()
};

spotifyCli.quit = function() {
  Application('Spotify').quit();
};

spotifyCli.parse(process.argv);
<commit_msg>adds next and prev commands<commit_after>#!/usr/bin/env node
/*
 * spotify-cli
 * https://github.com/shidel-dev/spotify-cli
 *
 * Copyright (c) 2014 shidel.dev
 * Licensed under the MIT license.
 */

var exec = require('child_process').exec;
var spotifyCli = require('commander');

function osa(osaFunction) {
  var args = Array.prototype.slice.call(arguments, 1, arguments.length - 1);
  var done = arguments[arguments.length - 1];
  var jsonArgs = args.map(JSON.stringify);
  var functionCallString = 'JSON.stringify((' + osaFunction.toString() + ')(' + jsonArgs.join(',') + '));';
  var escapedCall = functionCallString.replace(/^\s+/g, ' ').replace(/\n/g, '').replace(/'/g, "'\\''");
  var executeString = "osascript -l JavaScript -e '" + escapedCall + "'";
  exec(executeString);
};

spotifyCli.version('0.1.0');

spotifyCli
  .command('play')
  .description('Start playback')
  .action(function(){
    osa(spotifyCli.play)
  });

spotifyCli
  .command('pause')
  .description('Pause playback')
  .action(function(){
    osa(spotifyCli.pause)
  });

spotifyCli
  .command('open')
  .description('open the spotify application')
  .action(function(){
    osa(spotifyCli.open)
  });

spotifyCli
  .command('quit')
  .description('close the spotify application')
  .action(function(){
    osa(spotifyCli.quit)
  });

spotifyCli
  .command('next')
  .description('play the next track')
  .action(function(){
    osa(spotifyCli.next)
  });

spotifyCli
  .command('previous')
  .description('play the previous track')
  .action(function(){
    osa(spotifyCli.prev)
  });

spotifyCli
  .command('prev')
  .description('play the previous track')
  .action(function(){
    osa(spotifyCli.prev)
  });

spotifyCli.play = function() {
  Application('Spotify').play();
};

spotifyCli.pause = function() {
  Application('Spotify').pause();
};

spotifyCli.open = function() {
  Application('Spotify').activate();
};

spotifyCli.quit = function() {
  Application('Spotify').quit();
};

spotifyCli.next = function() {
  Application('Spotify').nextTrack();
};

spotifyCli.prev = function() {
  Application('Spotify').previousTrack();
};

spotifyCli.parse(process.argv);

{'fraction_non_alphanumeric': 0.1892542101042502, 'fraction_numerical': 0.005346164127238706, 'mean_word_length': 4.315340909090909, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '609372', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1241, 'n_words': 218}