"""This module provides a console interface to convert CSV to Google Sheets."""

from csv2googlesheets.gapi_authorization import auth_with_google
from csv2googlesheets.gapi_create_sheet import create_sheet
from csv2googlesheets.gapi_write_to_sheet import write_to_sheet

from csv2googlesheets.parse_file import build_spreadsheet_title
from csv2googlesheets.parse_file import parse_file
from csv2googlesheets.parse_cli_args import parse_cli_args


def main():
    """Control the flow of operations to write data from csv to G Sheets."""
    cli_args = parse_cli_args()
    values = parse_file(path=cli_args.csv)
    spreadsheet_title = build_spreadsheet_title(cli_args.csv)

    google_service = auth_with_google(path_creds=cli_args.credentials_json)
    spreadsheet_id = create_sheet(google_service, spreadsheet_title)

    write_to_sheet(
        google_service,
        sheet_id=spreadsheet_id,
        values=values,
        )


if __name__ == '__main__':
    main()

[((14, 15, 14, 31), 'csv2googlesheets.parse_cli_args.parse_cli_args', 'parse_cli_args', ({}, {}), '()', False, 'from csv2googlesheets.parse_cli_args import parse_cli_args\n'), ((15, 13, 15, 42), 'csv2googlesheets.parse_file.parse_file', 'parse_file', (), '', False, 'from csv2googlesheets.parse_file import parse_file\n'), ((16, 24, 16, 61), 'csv2googlesheets.parse_file.build_spreadsheet_title', 'build_spreadsheet_title', ({(16, 48, 16, 60): 'cli_args.csv'}, {}), '(cli_args.csv)', False, 'from csv2googlesheets.parse_file import build_spreadsheet_title\n'), ((18, 21, 18, 75), 'csv2googlesheets.gapi_authorization.auth_with_google', 'auth_with_google', (), '', False, 'from csv2googlesheets.gapi_authorization import auth_with_google\n'), ((19, 21, 19, 68), 'csv2googlesheets.gapi_create_sheet.create_sheet', 'create_sheet', ({(19, 34, 19, 48): 'google_service', (19, 50, 19, 67): 'spreadsheet_title'}, {}), '(google_service, spreadsheet_title)', False, 'from csv2googlesheets.gapi_create_sheet import create_sheet\n'), ((21, 4, 25, 9), 'csv2googlesheets.gapi_write_to_sheet.write_to_sheet', 'write_to_sheet', (), '', False, 'from csv2googlesheets.gapi_write_to_sheet import write_to_sheet\n')]