# Path: ledgerbil/ledgerbil.py
# def run_ledgerbil(args):
# def matching_account_found(ledgerfiles, reconcile_account):
# def get_args(args):
# def main(argv=None):
# 
# Path: ledgerbil/portfolio.py
# VALID_YEAR_KEYS = {"symbol", "price", "shares", "contributions", "transfers", "note"}
# NULL_GAIN = -1
# COL_GAIN = 7
# COL_CONTRIB = 9
# COL_TRANSFERS = 10
# COL_VALUE = 11
# COL_GAIN_VALUE = 11
# COL_NUM_YEARS = 2
# COL_ACCOUNT = 40
# COL_LABEL = 12
# COL_PERCENT = 3
# def get_portfolio_report(args):
# def strip_assets_prefix(s):
# def no_match(accounts_regex, labels, yearly=False):
# def get_matching_accounts(accounts_regex, labels_string=""):
# def get_list(accounts):
# def validate_json_year_keys(year):
# def get_performance_report_header(accounts, num_years):
# def get_performance_report(accounts, included_years):
# def get_annualized_total_return(gains, num_years):
# def get_formatted_gain(gains=None, num_years=1, annualized_total=None):
# def get_gain(gains, num_years):
# def get_performance_report_column_headers(num_years):
# def get_performance_report_years(years):
# def get_yearly_combined_accounts(accounts, included_years):
# def get_yearly_with_gains(totals):
# def get_history_report(matching_accounts):
# def get_account_history(account):
# def get_comparison_report_column_headers(num_years, labels=True):
# def get_sorted_comparison_items(comparison_items, sort):
# def get_comparison_report(
#     accounts, labels, accounts_regex, included_years, sort, accounts_only
# ):
# def get_comparison_summary(years, col1):
# def get_comparison_report_line(comparison_item, percent, labels):
# def get_portfolio_data():
# def get_args(args):
# def main(argv=None):
# 
# Path: ledgerbil/ledgershell/grid.py
# TOTAL_HEADER = "Total"
# SORT_DEFAULT = TOTAL_HEADER.lower()
# EMPTY_VALUE = ""
#     AMOUNT_WIDTH = 14  # width of columns with amounts
#     ACCOUNT_PAYEE_COLUMN = -1  # last column, aka row header
#     TOTAL_COLUMN = -2  # second to last column (*if* we have a total)
#     AMOUNT_COLUMN_START = 0  # inclusive
#         AMOUNT_COLUMN_END = TOTAL_COLUMN  # exclusive
#         AMOUNT_COLUMN_END = ACCOUNT_PAYEE_COLUMN  # exclusive
#     DATA_ROW_START = 1
#     DATA_ROW_END = -1 if has_total_row else len(rows)  # exclusive
#     HEADER_ROW = 0
#     FOOTER_ROW = -1 if has_total_row else None
#     TRUNC_CHAR = "~"
#     ACCOUNT_TYPES = ["assets:", "liabilities:", "income:", "expenses:", "equity:"]
#     HEADER_SPLIT = r"(?<=: )|(?<=:)(?=\S)|(?<=[- ])"
#     ACCOUNT_PAYEE_HEADER = EMPTY_VALUE
#     ACCOUNT_PAYEE_COLUMN = -1
#     TOTAL_COLUMN = -2
# def get_grid_report(args, ledger_args):
# def get_csv_report(rows, tabs=False):
# def get_flat_report(rows, networth=False):
# def get_flat_report_header(headers, width=14):
# def get_flat_report_header_lists(headers, width=14):
# def get_period_names(args, ledger_args, unit="year"):
# def get_columns(args, ledger_args, period_names, current_period=None):
# def get_column(args, ledger_args, period_name, ending):
# def get_column_accounts(period_name, ledger_args, depth=0):
# def validate_column_total(period_name, column_total=0, ledgers_total=0):
# def warn_column_total(period_name, column_total=0, ledgers_total=0):
# def get_column_payees(period_name, ledger_args):
# def get_column_networth(period_name, ledger_args):
# def get_rows(
#     row_headers,
#     columns,
#     period_names,
#     sort=SORT_DEFAULT,
#     limit_rows=0,
#     total_only=False,
#     no_total=False,
# ):
# def get_grid(row_headers, columns):
# def get_args(args):
# def main(argv=None):
# 
# Path: ledgerbil/ledgershell/investments.py
# def get_investment_command_options(accounts, end_date, shares=False):
# def warn_negative_dollars(amount, account):
# def get_lines(args, shares=False):
# def get_dollars(args):
# def get_shares(args):
# def get_investment_report(args):
# def get_args(args):
# def main(argv=None):
# 
# Path: ledgerbil/ledgershell/passthrough.py
# def get_args(args):
# def main(argv=None):


import sys
from ledgerbil import ledgerbil, portfolio
from ledgerbil.ledgershell import grid, investments, passthrough
#!/usr/bin/env python3



def main(argv=None):
    if argv is None:
        argv = sys.argv[1:]

    command = argv[0] if argv else ""

    other = {
        "grid": grid,
        "inv": investments,
        "investments": investments,
        "pass": passthrough,
        "port": portfolio,
        "portfolio": portfolio,
    }

    if command not in other:

# Path: ledgerbil/ledgerbil.py
# def run_ledgerbil(args):
# def matching_account_found(ledgerfiles, reconcile_account):
# def get_args(args):
# def main(argv=None):
# 
# Path: ledgerbil/portfolio.py
# VALID_YEAR_KEYS = {"symbol", "price", "shares", "contributions", "transfers", "note"}
# NULL_GAIN = -1
# COL_GAIN = 7
# COL_CONTRIB = 9
# COL_TRANSFERS = 10
# COL_VALUE = 11
# COL_GAIN_VALUE = 11
# COL_NUM_YEARS = 2
# COL_ACCOUNT = 40
# COL_LABEL = 12
# COL_PERCENT = 3
# def get_portfolio_report(args):
# def strip_assets_prefix(s):
# def no_match(accounts_regex, labels, yearly=False):
# def get_matching_accounts(accounts_regex, labels_string=""):
# def get_list(accounts):
# def validate_json_year_keys(year):
# def get_performance_report_header(accounts, num_years):
# def get_performance_report(accounts, included_years):
# def get_annualized_total_return(gains, num_years):
# def get_formatted_gain(gains=None, num_years=1, annualized_total=None):
# def get_gain(gains, num_years):
# def get_performance_report_column_headers(num_years):
# def get_performance_report_years(years):
# def get_yearly_combined_accounts(accounts, included_years):
# def get_yearly_with_gains(totals):
# def get_history_report(matching_accounts):
# def get_account_history(account):
# def get_comparison_report_column_headers(num_years, labels=True):
# def get_sorted_comparison_items(comparison_items, sort):
# def get_comparison_report(
#     accounts, labels, accounts_regex, included_years, sort, accounts_only
# ):
# def get_comparison_summary(years, col1):
# def get_comparison_report_line(comparison_item, percent, labels):
# def get_portfolio_data():
# def get_args(args):
# def main(argv=None):
# 
# Path: ledgerbil/ledgershell/grid.py
# TOTAL_HEADER = "Total"
# SORT_DEFAULT = TOTAL_HEADER.lower()
# EMPTY_VALUE = ""
#     AMOUNT_WIDTH = 14  # width of columns with amounts
#     ACCOUNT_PAYEE_COLUMN = -1  # last column, aka row header
#     TOTAL_COLUMN = -2  # second to last column (*if* we have a total)
#     AMOUNT_COLUMN_START = 0  # inclusive
#         AMOUNT_COLUMN_END = TOTAL_COLUMN  # exclusive
#         AMOUNT_COLUMN_END = ACCOUNT_PAYEE_COLUMN  # exclusive
#     DATA_ROW_START = 1
#     DATA_ROW_END = -1 if has_total_row else len(rows)  # exclusive
#     HEADER_ROW = 0
#     FOOTER_ROW = -1 if has_total_row else None
#     TRUNC_CHAR = "~"
#     ACCOUNT_TYPES = ["assets:", "liabilities:", "income:", "expenses:", "equity:"]
#     HEADER_SPLIT = r"(?<=: )|(?<=:)(?=\S)|(?<=[- ])"
#     ACCOUNT_PAYEE_HEADER = EMPTY_VALUE
#     ACCOUNT_PAYEE_COLUMN = -1
#     TOTAL_COLUMN = -2
# def get_grid_report(args, ledger_args):
# def get_csv_report(rows, tabs=False):
# def get_flat_report(rows, networth=False):
# def get_flat_report_header(headers, width=14):
# def get_flat_report_header_lists(headers, width=14):
# def get_period_names(args, ledger_args, unit="year"):
# def get_columns(args, ledger_args, period_names, current_period=None):
# def get_column(args, ledger_args, period_name, ending):
# def get_column_accounts(period_name, ledger_args, depth=0):
# def validate_column_total(period_name, column_total=0, ledgers_total=0):
# def warn_column_total(period_name, column_total=0, ledgers_total=0):
# def get_column_payees(period_name, ledger_args):
# def get_column_networth(period_name, ledger_args):
# def get_rows(
#     row_headers,
#     columns,
#     period_names,
#     sort=SORT_DEFAULT,
#     limit_rows=0,
#     total_only=False,
#     no_total=False,
# ):
# def get_grid(row_headers, columns):
# def get_args(args):
# def main(argv=None):
# 
# Path: ledgerbil/ledgershell/investments.py
# def get_investment_command_options(accounts, end_date, shares=False):
# def warn_negative_dollars(amount, account):
# def get_lines(args, shares=False):
# def get_dollars(args):
# def get_shares(args):
# def get_investment_report(args):
# def get_args(args):
# def main(argv=None):
# 
# Path: ledgerbil/ledgershell/passthrough.py
# def get_args(args):
# def main(argv=None):


# Path: main.py
import sys
from ledgerbil import ledgerbil, portfolio
from ledgerbil.ledgershell import grid, investments, passthrough

#!/usr/bin/env python3



def main(argv=None):
    if argv is None:
        argv = sys.argv[1:]

    command = argv[0] if argv else ""

    other = {
        "grid": grid,
        "inv": investments,
        "investments": investments,
        "pass": passthrough,
        "port": portfolio,
        "portfolio": portfolio,
    }

    if command not in other:

        return ledgerbil.main(argv)