()
| 94 | |
| 95 | |
| 96 | async def main(): |
| 97 | args = sys.argv[1:] |
| 98 | |
| 99 | if len(args) < 2: |
| 100 | print("Usage: python batch_add_link.py <links_file_or_raw> <platforms>") |
| 101 | print() |
| 102 | print("Batch add multiple TestFlight links that share the same platform(s).") |
| 103 | print() |
| 104 | print("Arguments:") |
| 105 | print(" links - A file path containing links (one per line),") |
| 106 | print(" or a string with links separated by newlines / commas") |
| 107 | print(" platforms - Comma-separated platforms (e.g. ios,ipados,macos,tvos,visionos)") |
| 108 | print() |
| 109 | print("Examples:") |
| 110 | print(" python3 batch_add_link.py links.txt ios") |
| 111 | print(" python3 batch_add_link.py 'AbcXYZ,Def123,Ghi456' ios,ipados") |
| 112 | print() |
| 113 | print(" File format (links.txt):") |
| 114 | print(" https://testflight.apple.com/join/AbcXYZ") |
| 115 | print(" https://testflight.apple.com/join/Def123") |
| 116 | print(" Ghi456") |
| 117 | sys.exit(1) |
| 118 | |
| 119 | raw_input = args[0] |
| 120 | platforms_str = args[1] |
| 121 | |
| 122 | # Parse platforms |
| 123 | tables = parse_platforms_from_string(platforms_str) |
| 124 | if not tables: |
| 125 | print(f"[error] No valid platforms found in: '{platforms_str}'") |
| 126 | print("Valid platforms: ios, ipados, macos, tvos, visionos") |
| 127 | sys.exit(1) |
| 128 | |
| 129 | # Parse links: try file first, then treat as raw string |
| 130 | from pathlib import Path |
| 131 | input_path = Path(raw_input) |
| 132 | if input_path.is_file(): |
| 133 | print(f"[info] Reading links from file: {input_path}") |
| 134 | raw_links = input_path.read_text(encoding='utf-8') |
| 135 | else: |
| 136 | raw_links = raw_input |
| 137 | |
| 138 | link_ids = parse_links(raw_links) |
| 139 | if not link_ids: |
| 140 | print("[error] No valid TestFlight links found in input") |
| 141 | sys.exit(1) |
| 142 | |
| 143 | # Deduplicate while preserving order |
| 144 | seen = set() |
| 145 | unique_links = [] |
| 146 | for lid in link_ids: |
| 147 | if lid not in seen: |
| 148 | seen.add(lid) |
| 149 | unique_links.append(lid) |
| 150 | link_ids = unique_links |
| 151 | |
| 152 | print(f"[info] Batch adding {len(link_ids)} link(s) for platform(s): {', '.join(tables)}") |
| 153 |
no test coverage detected