{"library":"docopt","code":"import os\nfrom docopt import docopt\n\nDOC = \"\"\"\nNaval Fate.\n\nUsage:\n  naval_fate.py ship new <name>...\n  naval_fate.py ship <name> move <x> <y> [--speed=<kn>]\n  naval_fate.py ship shoot <x> <y>\n  naval_fate.py mine (set|remove) <x> <y> [--moored | --drifting]\n  naval_fate.py (-h | --help)\n  naval_fate.py --version\n\nOptions:\n  -h --help     Show this screen.\n  --version     Show version.\n  --speed=<kn>  Speed in knots [default: 10].\n  --moored      Moored (anchored) mine.\n  --drifting    Drifting mine.\n\"\"\"\n\nif __name__ == '__main__':\n    # Simulate command-line arguments for demonstration\n    # In a real script, this would be docopt(__doc__, version='Naval Fate 2.0')\n    # For testing, you might pass a list of strings:\n    # arguments = docopt(DOC, argv=['ship', 'new', 'Argos', 'Bounty'], version='Naval Fate 2.0')\n    \n    # For a runnable quickstart, we'll parse the docstring without actual CLI input\n    # and assume a simple case. For full CLI testing, a dedicated test framework is better.\n    \n    # To make this runnable without actual CLI, we simulate argv.\n    # In a real scenario, remove `argv` parameter to let it use sys.argv\n    simulated_argv = os.environ.get('DOCOPT_SIM_ARGS', '').split() or ['ship', 'new', 'ExampleShip']\n    \n    # If --version is in simulated_argv, docopt will print version and exit.\n    # For quickstart, we'll avoid it unless specifically tested.\n    if '--version' in simulated_argv:\n        print('Naval Fate 2.0')\n        import sys\n        sys.exit(0)\n\n    arguments = docopt(DOC, argv=simulated_argv, version='Naval Fate 2.0')\n    print(arguments)\n\n    # Example of accessing parsed arguments\n    if arguments.get('ship') and arguments.get('new'):\n        print(f\"Creating new ship(s): {arguments['<name>']}\")\n","lang":"python","description":"This quickstart demonstrates how docopt parses command-line arguments based on a docstring. The `docopt` function takes the module's `__doc__` string (or any string describing the CLI interface) and an optional `argv` list (for testing/simulation) and returns a dictionary of parsed arguments and options. Run this script from the command line, for example, `python your_script.py ship new Enterprise` or by setting the `DOCOPT_SIM_ARGS` environment variable for in-code simulation.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}