<commit_before># ledger-cli

API for the Ledger command-line interface ([ledger-cli.org](http://ledger-cli.org/)).

> Ledger is a powerful, double-entry accounting system that is accessed from the UNIX command-line.

## Dependencies

Requires the Ledger to be installed, for Mac OS X using homebrew and latest 3.0 version.

    brew install ledger --HEAD

## Usage

Install dependencies with npm.

    npm install ledger-cli

Use the Ledger class to execute reports (only balance is currently supported).

    var Ledger = require('ledger-cli').Ledger;
    ledger = new Ledger({ file: 'path/to/ledger/journal/file.dat' });
    
### Balance    

The balance command reports the current balance of all accounts.

    ledger.balance()
      .on('data', function(entry) {
        // JSON object for each entry
        entry = {
          total: {
            currency: '£',
            amount: 1000,
            formatted: '£1,000.00'
          }, 
          account: { <commit_msg>Updated README with installation instructions.<commit_after># ledger-cli

API for the Ledger command-line interface ([ledger-cli.org](http://ledger-cli.org/)).

> Ledger is a powerful, double-entry accounting system that is accessed from the UNIX command-line.

## Dependencies

  * [Ledger 3](http://ledger-cli.org/)
  * [Node.js](nodejs.org) and npm

### Installing Ledger

The simplest way to install Ledger 3 is through [Homebrew](http://mxcl.github.com/homebrew/).

    brew install ledger --HEAD

The `--HEAD` option is required to install version 3.x.

## Usage

Install `ledger-cli` and its dependencies with npm.

    npm install ledger-cli

Use the Ledger class to execute reports (balance & register are currently supported).

    var Ledger = require('ledger-cli').Ledger;
    ledger = new Ledger({ file: 'path/to/ledger/journal/file.dat' });
    
### Balance    

The balance command reports the current balance of all accounts.

    ledger.balance()
      .on('data', function(entry) {
        // JSON object for each entry
        entry = {
          total: {
            currency: '£',
            amount: 1000,
            formatted: '£1,000.00'
          }, 
          account: { 
{'fraction_non_alphanumeric': 0.11075367647058823, 'fraction_numerical': 0.011488970588235295, 'mean_word_length': 2.622296173044925, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6450124', 'n_tokens_mistral': 668, 'n_tokens_neox': 624, 'n_words': 217}