874b6f20c2
Основа — Horizon (MIT). История апстрима не переносится: этот репозиторий ведёт свою.
43 lines
1.9 KiB
Python
43 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate crates/horizon-client/src/lan/command_suggestions.rs: the argument
|
|
nodes of vanilla's command tree that have a custom suggestion provider, and
|
|
the provider's network name (ClientboundCommandsPacket sends it; the commands
|
|
report does not). The list comes from VanillaCommandSuggestionsExporter run
|
|
against the pinned client jar:
|
|
|
|
javac --release 25 -proc:none -sourcepath mods/horizon/src/test/java -cp CLIENT_CP \\
|
|
-d BUILD mods/horizon/src/test/java/dev/horizonlab/parity/VanillaCommandSuggestionsExporter.java
|
|
java -cp BUILD:CLIENT_CP dev.horizonlab.parity.VanillaCommandSuggestionsExporter suggestions.tsv
|
|
generate_command_suggestions.py suggestions.tsv
|
|
"""
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
parser.add_argument("tsv", type=Path)
|
|
parser.add_argument("--out", type=Path, default=ROOT / "crates/horizon-client/src/lan/command_suggestions.rs")
|
|
args = parser.parse_args()
|
|
rows = sorted(tuple(line.split("\t")) for line in args.tsv.read_text().splitlines() if line.strip())
|
|
if len(rows) < 50:
|
|
raise SystemExit(f"only {len(rows)} nodes")
|
|
lines = [
|
|
"//! Argument nodes of vanilla's command tree with a custom suggestion",
|
|
"//! provider (path of node names from the root, provider network name).",
|
|
"//! Generated by tools/generate_command_suggestions.py from",
|
|
"//! VanillaCommandSuggestionsExporter; do not edit by hand.",
|
|
"",
|
|
"pub const SUGGESTIONS: &[(&str, &str)] = &[",
|
|
]
|
|
lines += [f' ("{path}", "{provider}"),' for path, provider in rows]
|
|
lines += ["];", ""]
|
|
args.out.write_text("\n".join(lines))
|
|
print(f"wrote {len(rows)} nodes to {args.out}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|