<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def main():
 """Generate a TPIP report."""

    parser = argparse.ArgumentParser(description='Generate a TPIP report as a CSV file.')
    parser.add_argument('output_filename', type=str, metavar='output-file',
                        help='the output path and filename', nargs='?')
    parser.add_argument('--only', type=str, help='only parse this package')
    args = parser.parse_args()

    output_path = os.path.abspath(args.output_filename) if args.output_filename else None

    skips = []
    tpip_pkgs = []
    for pkg_name, pkg_item in sorted(pkg_resources.working_set.by_key.items()):
        if args.only and args.only not in pkg_name.lower():
            continue
        if pkg_name in EXCLUDED_PACKAGES:
            skips.append(pkg_name)
            continue
        metadata_lines = get_metadata(pkg_item)
        tpip_pkg = process_metadata(pkg_name, metadata_lines)
        tpip_pkgs.append(force_ascii_values(tpip_pkg))

    print(json.dumps(tpip_pkgs, indent=2, sort_keys=True))
    print('Parsed %s packages\nOutput to CSV: `%s`\nIgnored packages: %s' % (
        len(tpip_pkgs),
        output_path,
        ', '.join(skips),
    ))
    output_path and write_csv_file(output_path, tpip_pkgs)