#!/usr/bin/env python
import argparse

from cover_letter_autofill_shared import export_cover_letter_to_text_file, export_cover_letter_to_pdf

def main():
    parser = argparse.ArgumentParser(description='Cover letter autofill')
    parser.add_argument('--company_name', '-cn', required=True, help='Company name')
    parser.add_argument('--hiring_manager_name', '-hmn', required=False, help='Hiring manager name')
    parser.add_argument('--company_commitment', '-cc', required=True, help='Company commitment', default='sustainable innovation')
    
    args = parser.parse_args()

    company_name = args.company_name
    hiring_manager_name = args.hiring_manager_name
    company_commitment = args.company_commitment
    
    print('\n')
    print('Arguments:')
    print(f'Company name: {company_name}')
    print(f'Hiring manager name: {hiring_manager_name}')
    
    subject, cover_letter = make_cover_letter_for_company(
        company_name = company_name, 
        hiring_manager_name = hiring_manager_name,
        company_commitment = company_commitment
    )

    print('\n')
    print(f'Subject: {subject}')
    print(f'Cover letter: {cover_letter}')

    export_cover_letter_to_text_file(cover_letter)
    export_cover_letter_to_pdf(cover_letter)

def make_cover_letter_for_company(company_name, hiring_manager_name, company_commitment):
    hiring_manager_name = "HR Team" if hiring_manager_name == "" else hiring_manager_name
    return "Experienced Web Developer - ERP Systems Specialist Seeking Opportunities", f"""
Dear {hiring_manager_name},

I'm writing to explore software engineering and data analysis opportunities at {company_name}. After researching your technical stack and business focus, I believe my experience developing integrated platforms and optimising data systems could bring immediate value to your team.

Throughout my career, I've focused on delivering end-to-end solutions that drive measurable business impact. Whether it's implementing new e-commerce platforms, optimising database performance, or creating automated processing systems, I combine technical excellence with a strong focus on business outcomes.

I'm particularly drawn to {company_name}'s commitment to {company_commitment} and would welcome the opportunity to discuss how my full-stack development experience could contribute to your continued growth. My CV is attached for you review.

Best regards,
Edward Middleton-Smith
edward.middletonsmith@gmail.com
07375571430
https://teddy.org.uk/
https://www.linkedin.com/in/teddyms/
https://github.com/Teddy-1024/
    """

if __name__ == '__main__':
    main()