Migrate your app to Rust, one piece at a time, checked against the original's recorded behavior at every step. TypeScript/JavaScript, Python, C, Go, Ruby, Java, Kotlin, PHP, C# and PowerShell
importjsonimportsysimporttextkitFUNCTIONS={"title_case":textkit.title_case,"format_number":textkit.format_number,"parse_kv":textkit.parse_kv,"wrap":textkit.wrap,}defmain():forlineinsys.stdin:ifnotline.strip():continuecall=json.loads(line)try:fn=FUNCTIONS.get(call["fn"])iffnisNone:raiseLookupError(f"unknown function {call['fn']}")out={"ok":fn(*call["args"])}exceptExceptionase:out={"error":f"{type(e).__name__}: {e}"}sys.stdout.write(json.dumps(out)+"\n")if__name__=="__main__":main()