MCPcopy Index your code
hub / github.com/Codeplain-ai/codeplain / main

Function main

plain2code.py:308–416  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

306
307
308def main(): # noqa: C901
309 if sys.platform == "win32":
310 sys.stdout.reconfigure(encoding="utf-8", errors="replace")
311 sys.stderr.reconfigure(encoding="utf-8", errors="replace")
312
313 args = parse_arguments()
314
315 # Handle --version flag before any other initialization
316 if args.version:
317 console.print(f"codeplain version {system_config.client_version}")
318 return
319
320 # Handle --status flag before any other initialization
321 if args.status:
322 if not args.api_key:
323 console.error(
324 "Your API key is required. Please set the CODEPLAIN_API_KEY environment variable or provide it with the --api-key argument.\n"
325 )
326 return
327
328 if not args.api:
329 args.api = "https://api.codeplain.ai"
330
331 try:
332 print_status(args.api_key, args.api, system_config.client_version)
333 except Exception as e:
334 console.error(f"Error fetching status: {str(e)}")
335 return
336
337 template_dirs = file_utils.get_template_directories(args.filename, args.template_dir, DEFAULT_TEMPLATE_DIRS)
338
339 # Handle full plain early-exit (raw text dump; does not require a parsed module).
340 if args.full_plain:
341 try:
342 module_name = Path(args.filename).stem
343 plain_source = plain_file.read_module_plain_source(module_name, template_dirs)
344 [full_plain_source, _] = file_utils.get_loaded_templates(template_dirs, plain_source)
345 console.info("Full plain text:\n")
346 console.info(full_plain_source)
347 except Exception as e:
348 console.error(f"Error: {str(e)}")
349 return
350
351 # Parse the plain file (and its required modules) once; reused by dry-run and rendering.
352 try:
353 plain_module = plain_modules.PlainModule(
354 args.filename,
355 args.build_folder,
356 args.conformance_tests_folder,
357 template_dirs,
358 )
359 except Exception as e:
360 console.error(f"Error: {str(e)}")
361 return
362
363 if args.dry_run:
364 console.info("Printing dry run output...\n")
365 render_range = plain_spec.compute_render_range(args, plain_module.plain_source)

Callers 1

plain2code.pyFile · 0.70

Calls 15

parse_argumentsFunction · 0.90
print_statusFunction · 0.90
print_dry_run_outputFunction · 0.90
EventBusClass · 0.90
RunStateClass · 0.90
initialize_telemetryFunction · 0.90
MissingAPIKeyClass · 0.90
dump_crash_logsFunction · 0.90
capture_crashFunction · 0.90
print_exit_summaryFunction · 0.90
setup_loggingFunction · 0.85

Tested by

no test coverage detected