<commit_before>/*
 * cushion-cli
 * https://github.com/stefanjudis/cushion-cli
 *
 * Copyright (c) 2012 <NAME>
 * Licensed under the MIT license.
 */

var documentCallbacks = module.exports = {},
    generalCallbacks = require('./generalCallbacks'),
    cli = require('../cliRunner'),
    clc = require('cli-color'),
    extend = require('node.extend');

// extend level commands with general commands
extend(documentCallbacks, generalCallbacks);


/**
 * Callback for content command
 *
 * @param  {Object} error    given error
 * @param  {Object} document document
 */
documentCallbacks.content = function(error, document) {
  if (typeof document.id === 'function') {
    console.log(clc.yellow('\nProperty set.\n'));
  } else {
    console.pretty(document);
  }

  cli.prompt();
};


/**
 * Callback for load command
 *
 * @param  {Object} error    given error
 * @param  {Object} document document
 */
documentCallbacks.load = function(error, document) {
  if (error) {
    documentCallbacks.showError(error);
  } else {
    cli.doc = document;
    console.log(clc.yellow('\nDocument loaded.\n'));
  }

  cli.prompt();
};


/**
 * Callback for save command
 *
 * @param  {Object} error    given error
 * @param  {Object} document document
 */
documentCallbacks.save = function(error, document) {
  if (cli.doc._id === undefined) {
    //cli.doc._id = document_id;
  }

  console.log(clc.yellow('\nDocument saved.\n'));
  cli.prompt();
};

documentCallbacks.info = documentCallbacks.simpleCallback;<commit_msg>fixed document save callback<commit_after>/*
 * cushion-cli
 * https://github.com/stefanjudis/cushion-cli
 *
 * Copyright (c) 2012 <NAME>
 * Licensed under the MIT license.
 */

var documentCallbacks = module.exports = {},
    generalCallbacks = require('./generalCallbacks'),
    cli = require('../cliRunner'),
    clc = require('cli-color'),
    extend = require('node.extend');

// extend level commands with general commands
extend(documentCallbacks, generalCallbacks);


/**
 * Callback for content command
 *
 * @param  {Object} error    given error
 * @param  {Object} document document
 */
documentCallbacks.content = function(error, document) {
  if (typeof document.id === 'function') {
    console.log(clc.yellow('\nProperty set.\n'));
  } else {
    console.pretty(document);
  }

  cli.prompt();
};


/**
 * Callback for load command
 *
 * @param  {Object} error    given error
 * @param  {Object} document document
 */
documentCallbacks.load = function(error, document) {
  if (error) {
    documentCallbacks.showError(error);
  } else {
    cli.doc = document;
    console.log(clc.yellow('\nDocument loaded.\n'));
  }

  cli.prompt();
};


/**
 * Callback for save command
 *
 * @param  {Object} error    given error
 * @param  {Object} document document
 */
documentCallbacks.save = function(error, document) {
  if (error) {
    documentCallbacks.showError(error);
  } else {
    if (cli.name === '...') {
      cli.name = document._id.substr(0, 8);
    }

    console.log(clc.yellow('\nDocument saved.\n'));
    cli.prompt();
  }
};

documentCallbacks.info = documentCallbacks.simpleCallback;
{'fraction_non_alphanumeric': 0.154338776817163, 'fraction_numerical': 0.003202049311559398, 'mean_word_length': 3.456490727532097, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4103895', 'n_tokens_mistral': 1004, 'n_tokens_neox': 960, 'n_words': 220}