prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  yaml_to_json add command line interface
  **Describe the bug**
  yaml_to_json currently only allow to enter filename. It is not convenient and cannot be used with bash autocomplete 
  
  **To Reproduce**
  
  **Expected behavior**
  Application should accept command line arguments with filenames
  
  **Screenshots**
  If applicable, add screenshots to help explain your problem.
  
  **Additional context**
  Add any other context about the problem here.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `yaml_to_json/yaml_to_json.py`
  Content:
  ```
  1 from ruyaml import YAML
  2 import json
  3 
  4 
  5 def get_yaml_data():
  6     yaml_name = input("Enter the yaml file name: ")
  7 
  8     try:
  9         with open(yaml_name, "r+") as f:
  10             yaml_data = YAML().load(f)
  11             return yaml_data
  12     except:  # noqa
  13         print("Invalid input enter a valid yaml file name e.g. example.yaml")
  14         yaml_data = get_yaml_data()
  15 
  16 
  17 def convert_to_json(yaml_data):
  18     json_name = input("Enter the name of output json file: ")
  19 
  20     try:
  21         with open(json_name, "w+") as o:
  22             o.write(json.dumps(yaml_data))
  23     except:  # noqa
  24         print("Invalid input enter a valid json file name e.g. example.json")
  25         convert_to_json(yaml_data)
  26 
  27 
  28 yaml_data = get_yaml_data()
  29 convert_to_json(yaml_data)
  30 
  31 print("Your yaml file has been converted and saved as json")
  32
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/yaml_to_json/yaml_to_json.py b/yaml_to_json/yaml_to_json.py
  --- a/yaml_to_json/yaml_to_json.py
  +++ b/yaml_to_json/yaml_to_json.py
  @@ -1,9 +1,11 @@
   from ruyaml import YAML
  +import argparse
   import json
   
   
  -def get_yaml_data():
  -    yaml_name = input("Enter the yaml file name: ")
  +def get_yaml_data(yaml_name=None):
  +    if not yaml_name:
  +        yaml_name = input("Enter the yaml file name: ")
   
       try:
           with open(yaml_name, "r+") as f:
  @@ -14,18 +16,34 @@
           yaml_data = get_yaml_data()
   
   
  -def convert_to_json(yaml_data):
  -    json_name = input("Enter the name of output json file: ")
  +def convert_to_json(yaml_data, json_name=None, intent=None):
  +    if not json_name:
  +        json_name = input("Enter the name of output json file: ")
   
       try:
           with open(json_name, "w+") as o:
  -            o.write(json.dumps(yaml_data))
  +            o.write(json.dumps(yaml_data, indent=intent))
       except:  # noqa
           print("Invalid input enter a valid json file name e.g. example.json")
           convert_to_json(yaml_data)
   
   
  -yaml_data = get_yaml_data()
  -convert_to_json(yaml_data)
  +def main():
  +    parser = argparse.ArgumentParser(description='Convert YAML file to JSON')
  +    parser.add_argument('--yaml', type=str, help='YAML filename')
  +    parser.add_argument('--json', type=str, help='JSON filename')
  +    parser.add_argument('--intent', type=int, help="intent value for JSON")
  +    args = parser.parse_args()
   
  -print("Your yaml file has been converted and saved as json")
  +    yaml_name = args.yaml
  +    json_name = args.json
  +    intent = args.intent
  +
  +    yaml_data = get_yaml_data(yaml_name)
  +    convert_to_json(yaml_data, json_name, intent=intent)
  +
  +    print("Your yaml file has been converted and saved as json")
  +
  +
  +if __name__ == "__main__":
  +    main()
  
verification_info: {"golden_diff": "diff --git a/yaml_to_json/yaml_to_json.py b/yaml_to_json/yaml_to_json.py\n--- a/yaml_to_json/yaml_to_json.py\n+++ b/yaml_to_json/yaml_to_json.py\n@@ -1,9 +1,11 @@\n from ruyaml import YAML\n+import argparse\n import json\n \n \n-def get_yaml_data():\n-    yaml_name = input(\"Enter the yaml file name: \")\n+def get_yaml_data(yaml_name=None):\n+    if not yaml_name:\n+        yaml_name = input(\"Enter the yaml file name: \")\n \n     try:\n         with open(yaml_name, \"r+\") as f:\n@@ -14,18 +16,34 @@\n         yaml_data = get_yaml_data()\n \n \n-def convert_to_json(yaml_data):\n-    json_name = input(\"Enter the name of output json file: \")\n+def convert_to_json(yaml_data, json_name=None, intent=None):\n+    if not json_name:\n+        json_name = input(\"Enter the name of output json file: \")\n \n     try:\n         with open(json_name, \"w+\") as o:\n-            o.write(json.dumps(yaml_data))\n+            o.write(json.dumps(yaml_data, indent=intent))\n     except:  # noqa\n         print(\"Invalid input enter a valid json file name e.g. example.json\")\n         convert_to_json(yaml_data)\n \n \n-yaml_data = get_yaml_data()\n-convert_to_json(yaml_data)\n+def main():\n+    parser = argparse.ArgumentParser(description='Convert YAML file to JSON')\n+    parser.add_argument('--yaml', type=str, help='YAML filename')\n+    parser.add_argument('--json', type=str, help='JSON filename')\n+    parser.add_argument('--intent', type=int, help=\"intent value for JSON\")\n+    args = parser.parse_args()\n \n-print(\"Your yaml file has been converted and saved as json\")\n+    yaml_name = args.yaml\n+    json_name = args.json\n+    intent = args.intent\n+\n+    yaml_data = get_yaml_data(yaml_name)\n+    convert_to_json(yaml_data, json_name, intent=intent)\n+\n+    print(\"Your yaml file has been converted and saved as json\")\n+\n+\n+if __name__ == \"__main__\":\n+    main()\n", "issue": "yaml_to_json add command line interface\n**Describe the bug**\r\nyaml_to_json currently only allow to enter filename. It is not convenient and cannot be used with bash autocomplete \r\n\r\n**To Reproduce**\r\n\r\n**Expected behavior**\r\nApplication should accept command line arguments with filenames\r\n\r\n**Screenshots**\r\nIf applicable, add screenshots to help explain your problem.\r\n\r\n**Additional context**\r\nAdd any other context about the problem here.\n", "before_files": [{"content": "from ruyaml import YAML\nimport json\n\n\ndef get_yaml_data():\n    yaml_name = input(\"Enter the yaml file name: \")\n\n    try:\n        with open(yaml_name, \"r+\") as f:\n            yaml_data = YAML().load(f)\n            return yaml_data\n    except:  # noqa\n        print(\"Invalid input enter a valid yaml file name e.g. example.yaml\")\n        yaml_data = get_yaml_data()\n\n\ndef convert_to_json(yaml_data):\n    json_name = input(\"Enter the name of output json file: \")\n\n    try:\n        with open(json_name, \"w+\") as o:\n            o.write(json.dumps(yaml_data))\n    except:  # noqa\n        print(\"Invalid input enter a valid json file name e.g. example.json\")\n        convert_to_json(yaml_data)\n\n\nyaml_data = get_yaml_data()\nconvert_to_json(yaml_data)\n\nprint(\"Your yaml file has been converted and saved as json\")\n", "path": "yaml_to_json/yaml_to_json.py"}], "after_files": [{"content": "from ruyaml import YAML\nimport argparse\nimport json\n\n\ndef get_yaml_data(yaml_name=None):\n    if not yaml_name:\n        yaml_name = input(\"Enter the yaml file name: \")\n\n    try:\n        with open(yaml_name, \"r+\") as f:\n            yaml_data = YAML().load(f)\n            return yaml_data\n    except:  # noqa\n        print(\"Invalid input enter a valid yaml file name e.g. example.yaml\")\n        yaml_data = get_yaml_data()\n\n\ndef convert_to_json(yaml_data, json_name=None, intent=None):\n    if not json_name:\n        json_name = input(\"Enter the name of output json file: \")\n\n    try:\n        with open(json_name, \"w+\") as o:\n            o.write(json.dumps(yaml_data, indent=intent))\n    except:  # noqa\n        print(\"Invalid input enter a valid json file name e.g. example.json\")\n        convert_to_json(yaml_data)\n\n\ndef main():\n    parser = argparse.ArgumentParser(description='Convert YAML file to JSON')\n    parser.add_argument('--yaml', type=str, help='YAML filename')\n    parser.add_argument('--json', type=str, help='JSON filename')\n    parser.add_argument('--intent', type=int, help=\"intent value for JSON\")\n    args = parser.parse_args()\n\n    yaml_name = args.yaml\n    json_name = args.json\n    intent = args.intent\n\n    yaml_data = get_yaml_data(yaml_name)\n    convert_to_json(yaml_data, json_name, intent=intent)\n\n    print(\"Your yaml file has been converted and saved as json\")\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "yaml_to_json/yaml_to_json.py"}]}