hledger-flags
Parses hledger flags
Last updated 4 years ago by rstacruz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install hledger-flags 
SYNC missed versions from official npm registry.

hledger-flags

Parses hledger flags

> parse('-f ledger.journal bal -M')
{
  command: 'balance',
  file: 'ledger.journal',
  query: [],
  monthly: true
}

Parses flags for hledger. Knows most of hledger's flag aliases and other quirks.

Status

API

OPTIONS

Options for rminimist.

> OPTIONS.boolean
[ 'ignore-assertions', 'cleared', 'pending', ... ]

> OPTIONS.string
[ 'file', 'begin', 'end', ... ]

> OPTIONS.alias
{ f: 'file', b: 'begin', e: 'end', ... }

parse

parse(string)

Parses a string into a Ledger Flags object.

> parse('-f ledger.journal bal -M')
{
  command: 'balance',
  file: 'ledger.journal',
  query: [],
  monthly: true
}

The return value is an object that always has the following fields:

  • command (String) - the command to be executed
  • query (Array) - query to run

All other attributes are derived from the flags.

normalizeCommand

normalizeCommand(cmd)

Normalizes a command based on aliases.

> normalizeCommand('reg')
'register'

> normalizeCommand('bal')
'balance'

toString

toString(flags)

Converts Ledger Flags back into string.

> args = parse('bal -f ledger.journal -M');
> toString(args)
'balance --file ledger.journal --monthly'

parseMany

parseMany(strings...)

Parses many arguments.

> args = parseMany('-f ledger.journal', 'bal -M');
> toString(args)
'balance --file ledger.journal --monthly'

See also

Thanks

hledger-flags © 2016+, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors (list).

ricostacruz.com  ·  GitHub @rstacruz  ·  Twitter @rstacruz

Current Tags

  • 1.0.0                                ...           latest (4 years ago)

1 Versions

  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |