defmain()->None:"""Sort `mike`'s `version.json` file with a custom order. The versions are sorted using `sort_versions()`. If no arguments are given, then the contents are read from stdin and the sorted versions are printed to stdout. If one argument is given, then the contents of the file are replaced with the sorted versions. If more than one argument is given, then an error is printed to stderr and the program exits with a non-zero exit code. """github.configure_logging()matchlen(sys.argv):case1:_dump_versions_to(_load_and_sort_versions_from(sys.stdin),sys.stdout)case2:withopen(sys.argv[1],"r",encoding="utf8")asstream_in:versions=_load_and_sort_versions_from(stream_in)withopen(sys.argv[1],"w",encoding="utf8")asstream_out:_dump_versions_to(versions,stream_out)case_:print(f"""\Usage: {sys.argv[0]} [<versions.json>]If <versions.json> is given, the contents will be replaced with the sorted versions.Otherwise, the contents are read from stdin and the sorted versions are printed to stdout.""",file=sys.stderr,)sys.exit(2)