From e8ff5db786fe0f4fae24fece1f41985c4c7808c5 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sun, 1 Feb 2026 18:20:22 +0000 Subject: [PATCH] fix: resolve CI workflow issues --- __main__.py | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 __main__.py diff --git a/__main__.py b/__main__.py new file mode 100644 index 0000000..aeff659 --- /dev/null +++ b/__main__.py @@ -0,0 +1,75 @@ +""" +cURL to Code Converter + +A CLI tool that converts cURL commands into code snippets in various programming languages. +""" + +import argparse +import sys +from curl_to_code_converter.parser import CurlParser +from curl_to_code_converter.generators import CodeGenerators + + +def main(): + parser = argparse.ArgumentParser( + description="Convert cURL commands to code snippets in various languages", + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=""" +Examples: + %(prog)s 'curl https://api.example.com/data' + %(prog)s 'curl -X POST https://api.example.com -d "{\"key\":\"value\"}"' -l python + %(prog)s 'curl -H "Authorization: Bearer token" https://api.example.com' -l javascript + """ + ) + parser.add_argument( + "curl_command", + help="The cURL command to convert" + ) + parser.add_argument( + "-l", "--language", + choices=["python", "javascript", "go", "ruby", "php", "java"], + default="python", + help="Target programming language (default: python)" + ) + parser.add_argument( + "-o", "--output", + help="Output file path (optional)" + ) + parser.add_argument( + "-v", "--verbose", + action="store_true", + help="Show verbose output" + ) + + args = parser.parse_args() + + try: + curl_parser = CurlParser(args.curl_command) + parsed_data = curl_parser.parse() + + if args.verbose: + print(f"Parsed cURL command:") + print(f" URL: {parsed_data.url}") + print(f" Method: {parsed_data.method}") + print(f" Headers: {parsed_data.headers}") + print(f" Data: {parsed_data.data}") + print(f" Auth: {parsed_data.auth}") + print() + + generators = CodeGenerators() + code = generators.generate(parsed_data, args.language) + + if args.output: + with open(args.output, 'w') as f: + f.write(code) + print(f"Code written to {args.output}") + else: + print(code) + + except Exception as e: + print(f"Error: {e}", file=sys.stderr) + sys.exit(1) + + +if __name__ == "__main__": + main()