#!/usr/bin/env python
"""
    Usage:
        ledgerplot [options]
    
    Options:
        --ledger <ledger file>
        --income_vs_expenses [<year>|<start date> <end date> [total]]
        -V, --version
"""

"""
See LICENSE.txt file for copyright and license details.
"""

from docopt import docopt
import sys


__all__ = ['ledgerplot']
__version__ = 'v0.1'

class PlotIncomeVsExpensesType():
    ALL_DATA_UNTIL_NOW = 0
    ALL_DATA_FOR_GIVEN_YEAR = 1
    ALL_DATA_FOR_GIVEN_PERIOD = 2
    ALL_DATA_FOR_GIVEN_PERIOD_TOTAL = 3
    
if __name__ == "__main__":
    args = docopt(__doc__, help=True, version=__version__)
    
    if args['--ledger']:
        ledger_file = args['--ledger']
        print 'Using ledger file %s'.format(ledger_file)
        
    if args['--income_vs_expenses']:
        from plot_income_vs_expenses import PlotIncomeVsExpenses
        plot = PlotIncomeVsExpenses()
        arglen = len(args['--income_vs_expenses'])
        print '-TEST- len(args[--income_vs_expenses]=%d'.format(arglen)
        if arglen = 3:
            plot.prepare_data(PlotIncomeVsExpensesType.ALL_DATA_FOR_GIVEN_PERIOD_TOTAL)
        elif arglen = 2:
            plot.prepare_data(PlotIncomeVsExpensesType.ALL_DATA_FOR_GIVEN_PERIOD)
        elif arglen = 1:
            plot.prepare_data(PlotIncomeVsExpensesType.ALL_DATA_FOR_GIVEN_YEAR)
        elif arglen = 0:
            plot.prepare_data(PlotIncomeVsExpensesType.ALL_DATA_UNTIL_NOW)
        else:
            print 'Too many arguments.'
            
        plot = None
    sys.exit(0)

@@ -308,16 +308,43 @@
 rt sys%0A%0A
+from constant.py import *%0A%0A
 %0A__all__
@@ -385,176 +385,8 @@
 0.1'
-%0A%0Aclass PlotIncomeVsExpensesType():%0A    ALL_DATA_UNTIL_NOW = 0%0A    ALL_DATA_FOR_GIVEN_YEAR = 1%0A    ALL_DATA_FOR_GIVEN_PERIOD = 2%0A    ALL_DATA_FOR_GIVEN_PERIOD_TOTAL = 3
 %0A   

Use constant.py