forked from gaugendre/ofx-processor
Update docs and reorder commands
This commit is contained in:
parent
eef563ac7c
commit
bbc60b0e01
7 changed files with 27 additions and 12 deletions
11
README.md
11
README.md
|
@ -21,15 +21,18 @@
|
||||||
```shell script
|
```shell script
|
||||||
Usage: ynab [OPTIONS] COMMAND [ARGS]...
|
Usage: ynab [OPTIONS] COMMAND [ARGS]...
|
||||||
|
|
||||||
|
Import your data to YNAB with the processors listed below or manage your
|
||||||
|
config.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--version Show the version and exit.
|
--version Show the version and exit.
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
bpvf Process BPVF bank statement (OFX)
|
config Manage configuration.
|
||||||
ce Process CE bank statement (OFX)
|
bpvf Import BPVF bank statement (OFX file).
|
||||||
config
|
ce Import CE bank statement (OFX file).
|
||||||
revolut Process Revolut bank statement (CSV)
|
revolut Import Revolut bank statement (CSV file).
|
||||||
```
|
```
|
||||||
|
|
||||||
All transactions will be pushed to YNAB. If this is your first time using the script,
|
All transactions will be pushed to YNAB. If this is your first time using the script,
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from ofx_processor.utils import ynab
|
from ofx_processor.utils import ynab
|
||||||
from ofx_processor.utils.utils import discover_processors
|
from ofx_processor.utils.utils import discover_processors, OrderedGroup
|
||||||
|
|
||||||
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
|
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
|
||||||
|
|
||||||
|
|
||||||
@click.group(context_settings=CONTEXT_SETTINGS)
|
@click.group(context_settings=CONTEXT_SETTINGS, cls=OrderedGroup)
|
||||||
@click.version_option()
|
@click.version_option()
|
||||||
def cli():
|
def cli():
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -57,7 +57,8 @@ class BpvfProcessor(Processor):
|
||||||
return ofx.statements[0].transactions
|
return ofx.statements[0].transactions
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@click.command("bpvf", help="Process BPVF bank statement (OFX)")
|
@click.command("bpvf")
|
||||||
@click.argument("ofx_filename")
|
@click.argument("ofx_filename")
|
||||||
def main(ofx_filename):
|
def main(ofx_filename):
|
||||||
|
"""Import BPVF bank statement (OFX file)."""
|
||||||
BpvfProcessor(ofx_filename).push_to_ynab()
|
BpvfProcessor(ofx_filename).push_to_ynab()
|
||||||
|
|
|
@ -25,7 +25,8 @@ class CeProcessor(BpvfProcessor):
|
||||||
line_class = CeLine
|
line_class = CeLine
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@click.command("ce", help="Process CE bank statement (OFX)")
|
@click.command("ce")
|
||||||
@click.argument("ofx_filename")
|
@click.argument("ofx_filename")
|
||||||
def main(ofx_filename):
|
def main(ofx_filename):
|
||||||
|
"""Import CE bank statement (OFX file)."""
|
||||||
CeProcessor(ofx_filename).push_to_ynab()
|
CeProcessor(ofx_filename).push_to_ynab()
|
||||||
|
|
|
@ -62,7 +62,8 @@ class RevolutProcessor(Processor):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@click.command("revolut", help="Process Revolut bank statement (CSV)")
|
@click.command("revolut")
|
||||||
@click.argument("csv_filename")
|
@click.argument("csv_filename")
|
||||||
def main(csv_filename):
|
def main(csv_filename):
|
||||||
|
"""Import Revolut bank statement (CSV file)."""
|
||||||
RevolutProcessor(csv_filename).push_to_ynab()
|
RevolutProcessor(csv_filename).push_to_ynab()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import collections
|
||||||
import importlib
|
import importlib
|
||||||
import pkgutil
|
import pkgutil
|
||||||
|
|
||||||
|
@ -25,3 +26,13 @@ def discover_processors(cli: click.Group):
|
||||||
if item.endswith("Processor") and item != "Processor":
|
if item.endswith("Processor") and item != "Processor":
|
||||||
cls = getattr(module, item)
|
cls = getattr(module, item)
|
||||||
cli.add_command(cls.main)
|
cli.add_command(cls.main)
|
||||||
|
|
||||||
|
|
||||||
|
class OrderedGroup(click.Group):
|
||||||
|
def __init__(self, name=None, commands=None, **attrs):
|
||||||
|
super(OrderedGroup, self).__init__(name, commands, **attrs)
|
||||||
|
#: the registered subcommands by their exported names.
|
||||||
|
self.commands = commands or collections.OrderedDict()
|
||||||
|
|
||||||
|
def list_commands(self, ctx):
|
||||||
|
return self.commands
|
||||||
|
|
|
@ -30,9 +30,7 @@ def get_config_file_name():
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
def config():
|
def config():
|
||||||
"""
|
"""Manage configuration."""
|
||||||
Manage configuration with subcommands
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
@config.command("edit")
|
@config.command("edit")
|
||||||
|
|
Loading…
Reference in a new issue