[mini] Support loading multiple profilers with the --profile option.
[mono-project.git] / scripts / submodules / versions.py
blob5252ee58306a6b9f77b257c92a5f0b391fd430db
1 #!/usr/bin/env python
3 import sys
4 import json
6 def find_module(submodules, name):
7 for item in submodules:
8 if item["name"] == name:
9 return item
11 print("Not found")
12 sys.exit(1)
15 if len(sys.argv) < 3:
16 print("Usage: versions.py <path to SUBMODULES.json> <command>")
17 sys.exit(1)
19 CONFIG_FILE = sys.argv[1]
20 command = sys.argv[2]
22 submodules = json.load(open(CONFIG_FILE))
24 if command == "get-rev":
25 mod = find_module(submodules, sys.argv[3])
26 print(mod["rev"])
27 elif command == "get-url":
28 mod = find_module(submodules, sys.argv[3])
29 print(mod["url"])
30 elif command == "get-dir":
31 mod = find_module(submodules, sys.argv[3])
32 print(mod["directory"])
33 elif command == "get-remote-branch":
34 mod = find_module(submodules, sys.argv[3])
35 print(mod["remote-branch"])
36 elif command == "set-rev":
37 mod = find_module(submodules, sys.argv[3])
38 mod["rev"] = sys.argv[4]
39 json.dump(submodules, open(CONFIG_FILE, "w"), indent = 2)
40 elif command == "set-branch":
41 mod = find_module(submodules, sys.argv[3])
42 mod["branch"] = sys.argv[4]
43 json.dump(submodules, open(CONFIG_FILE, "w"), indent = 2)
44 elif command == "set-remote-branch":
45 mod = find_module(submodules, sys.argv[3])
46 mod["remote-branch"] = sys.argv[4]
47 json.dump(submodules, open(CONFIG_FILE, "w"), indent = 2)
48 elif command == "cat":
49 print(json.dumps(submodules, indent = 2))
50 else:
51 print("Unknown command "" + command + "".")
52 sys.exit(1)