<commit_before>#!/usr/bin/env node

var fs = require('fs'),
  colors = require('colors'),
  username = require('username'),
  autostart = require('./lib/index.js'),
  argv = require('yargs')
  .usage('Usage: $0 <command> [options]')
  .command('enable', 'Enable autostart here with a custom key', function(yargs) {
    argv = yargs
      .option('n', {
        demand: true,
        alias: 'name',
        describe: 'Name of the key for identifying startup objecst',
        type: 'string',
        nargs: 1
      })
      .option('c', {
        demand: false,
        alias: 'command',
        describe: 'Command to execute in the path',
        type: 'string',
        default: 'npm start'
      })
      .option('p', {
        demand: false,
        alias: 'path',
        describe: 'Place of execution of command',
        type: 'string',
        default: process.cwd()
      })
      .help('h')
      .alias('h', 'help')
      .showHelpOnFail(false, 'Use --help for further information')
      .argv;

    autostart.enableAutostart(argv.n, argv.c, argv.p, function(err) {
      if (err) {
        console.error('An error occured while trying to enable autostart, here are the details:');
        console.error(err);
        process.exit(1);
      }

      console.log('Done!');
      process.exit(0);
    });
  })
  .command('disable', 'Disable autostart with key', function(yargs) {
    argv = yargs
      .option('n', {
        demand: true,
        alias: 'name',
        describe: 'Name of the key for identifying startup objecst',
        type: 'string',
        nargs: 1
      })
      .help('h')
      .alias('h', 'help')
      .showHelpOnFail(false, 'Use --help for further information')
      .argv;

    autostart.disableAutostart(argv.n, function(err) {
      if (err) {
        console.error('An error occured while trying to disable autostart, here are the details:');
        console.error(err);
        process.exit(1);
      }

      console.log('Done!');
      process.exit(0);
    });
  })
  .command('check', 'Check if autostart is enabled by key', function(yargs) {
    argv = yargs
      .option('n', {
        demand: true,
        alias: 'name',
        describe: 'Name of the key for identifying startup objects',
        type: 'string',
        nargs: 1
      })
      .help('h')
      .alias('h', 'help')
      .showHelpOnFail(false, 'Use --help for further information')
      .argv;

    autostart.isAutostartEnabled(argv.n, function(isEnabled, err) {
      if (err) {
        console.error('An error occured while trying to check if autostart is enabled, here are the details:');
        console.error(err);
        process.exit(1);
      }

      console.log("Done!");
      if (isEnabled) {
        console.log('Autostart is enabled');
        process.exit(0);
      } else if (!isEnabled) {
        console.log('Autostart is not enabled');
        process.exit(0);
      }
    });
  })
  .command('doctor', 'See all enabled autostart services', function(yargs) {
    argv = yargs
      .help('h')
      .alias('h', 'help')
      .showHelpOnFail(false, 'Use --help for further information')
      .argv;

    try {
      fs.statSync((process.env.HOME || process.env.USERPROFILE) + '/.autostart.json');
    } catch (e) {
      console.error('No .autostart file for the user ' + username.sync() + ' found. Aborting.');
      process.exit(1);
    }

    var services = JSON.parse(fs.readFileSync((process.env.HOME || process.env.USERPROFILE) + '/.autostart.json', 'utf-8'));

    console.log('These services are currently active:\n');

    Object.keys(services).forEach(function(key) {
      console.log(('"' + key + '":').inverse + (' ' + services[key]).green);
    });
  })
  .demand(1)
  .help('h')
  .alias('h', 'help')
  .showHelpOnFail(false, 'Use --help for further information')
  .argv;<commit_msg>Update CLI beahviour<commit_after>#!/usr/bin/env node

var fs = require('fs'),
  colors = require('colors'),
  username = require('username'),
  autostart = require('./lib/index.js'),
  argv = require('yargs')
  .usage('Usage: $0 <command> [options]')
  .command('enable', 'Enable autostart here with a custom key', function(yargs) {
    argv = yargs
      .option('n', {
        demand: true,
        alias: 'name',
        describe: 'Name of the key for identifying startup objecst',
        type: 'string',
        nargs: 1
      })
      .option('c', {
        demand: false,
        alias: 'command',
        describe: 'Command to execute in the path',
        type: 'string',
        default: 'npm start'
      })
      .option('p', {
        demand: false,
        alias: 'path',
        describe: 'Place of execution of command',
        type: 'string',
        default: process.cwd()
      })
      .help('h')
      .alias('h', 'help')
      .showHelpOnFail(false, 'Use --help for further information')
      .argv;

    autostart.enableAutostart(argv.n, argv.c, argv.p, function(err) {
      if (err) {
        console.error('An error occured while trying to enable autostart, here are the details:');
        console.error(err);
        process.exit(1);
      }

      console.log('Done!');
      process.exit(0);
    });
  })
  .command('disable', 'Disable autostart with key', function(yargs) {
    argv = yargs
      .option('n', {
        demand: true,
        alias: 'name',
        describe: 'Name of the key for identifying startup objecst',
        type: 'string',
        nargs: 1
      })
      .help('h')
      .alias('h', 'help')
      .showHelpOnFail(false, 'Use --help for further information')
      .argv;

    autostart.disableAutostart(argv.n, function(err) {
      if (err) {
        console.error('An error occured while trying to disable autostart, here are the details:');
        console.error(err);
        process.exit(1);
      }

      console.log('Done!');
      process.exit(0);
    });
  })
  .command('check', 'Check if autostart is enabled by key', function(yargs) {
    argv = yargs
      .option('n', {
        demand: true,
        alias: 'name',
        describe: 'Name of the key for identifying startup objects',
        type: 'string',
        nargs: 1
      })
      .help('h')
      .alias('h', 'help')
      .showHelpOnFail(false, 'Use --help for further information')
      .argv;

    autostart.isAutostartEnabled(argv.n, function(isEnabled, err) {
      if (err) {
        console.error('An error occured while trying to check if autostart is enabled, here are the details:');
        console.error(err);
        process.exit(1);
      }

      console.log("Done!");
      if (isEnabled) {
        console.log('Autostart is enabled');
        process.exit(0);
      } else if (!isEnabled) {
        console.log('Autostart is not enabled');
        process.exit(0);
      }
    });
  })
  .command('doctor', 'See all enabled autostart services', function(yargs) {
    argv = yargs
      .help('h')
      .alias('h', 'help')
      .showHelpOnFail(false, 'Use --help for further information')
      .argv;

    try {
      fs.statSync((process.env.HOME || process.env.USERPROFILE) + '/.autostart.json');
    } catch (e) {
      console.error('No .autostart file for the user ' + username.sync() + ' found. Aborting.');
      process.exit(1);
    }

    var services = JSON.parse(fs.readFileSync((process.env.HOME || process.env.USERPROFILE) + '/.autostart.json', 'utf-8'));

    if(!Object.keys(services).length) {
      console.log('No services enabled.'.red);
      process.exit(0);
    }

    console.log('These services are currently active:');

    Object.keys(services).forEach(function(key) {
      console.log(('"' + key + '":').inverse + (' ' + services[key]).green);
    });
  })
  .demand(1)
  .help('h')
  .alias('h', 'help')
  .showHelpOnFail(false, 'Use --help for further information')
  .argv;
{'fraction_non_alphanumeric': 0.15970264034862855, 'fraction_numerical': 0.0037169956421430404, 'mean_word_length': 2.323253833049404, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '6895826', 'n_tokens_mistral': 2468, 'n_tokens_neox': 2426, 'n_words': 614}