Main function to extract task details and generate CSV. Args: output_file: Optional path to save the TSV file to quiet: If True, suppress verbose output
(output_file: Path | None = None, quiet: bool = False)
| 161 | |
| 162 | |
| 163 | def main(output_file: Path | None = None, quiet: bool = False): |
| 164 | """Main function to extract task details and generate CSV. |
| 165 | |
| 166 | Args: |
| 167 | output_file: Optional path to save the TSV file to |
| 168 | quiet: If True, suppress verbose output |
| 169 | """ |
| 170 | # Get the tasks directory |
| 171 | script_dir = Path(__file__).parent |
| 172 | project_root = script_dir.parent |
| 173 | tasks_dir = project_root / "tasks" |
| 174 | |
| 175 | if not tasks_dir.exists(): |
| 176 | print(f"Error: Tasks directory not found at {tasks_dir}") |
| 177 | sys.exit(1) |
| 178 | |
| 179 | if not quiet: |
| 180 | print(f"Extracting task details from {tasks_dir}...") |
| 181 | |
| 182 | # Extract task details |
| 183 | task_details = extract_task_details(tasks_dir) |
| 184 | |
| 185 | if not task_details: |
| 186 | print("No task details found!") |
| 187 | sys.exit(1) |
| 188 | |
| 189 | # Create DataFrame |
| 190 | df = pd.DataFrame(task_details) |
| 191 | |
| 192 | # Reorder columns as requested |
| 193 | column_order = [ |
| 194 | "status", |
| 195 | "task_id", |
| 196 | "database_types", |
| 197 | "project_types", |
| 198 | "project_name", |
| 199 | "database_name", |
| 200 | "key", |
| 201 | "description", |
| 202 | "prompt", |
| 203 | "notes", |
| 204 | "difficulty", |
| 205 | "tags", |
| 206 | ] |
| 207 | |
| 208 | df = df[column_order] |
| 209 | |
| 210 | # Sort by task_id and key |
| 211 | df = df.sort_values(["task_id", "key"]) |
| 212 | |
| 213 | # Generate TSV for clipboard (better for Google Sheets) |
| 214 | tsv_content = df.to_csv(index=False, sep="\t") |
| 215 | |
| 216 | # Save to file if output_file is provided |
| 217 | if output_file: |
| 218 | output_file.parent.mkdir(parents=True, exist_ok=True) |
| 219 | with open(output_file, "w", encoding="utf-8") as f: |
| 220 | f.write(tsv_content) |
no test coverage detected