-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
tasks.py
53 lines (42 loc) · 1.17 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import shutil
from pathlib import Path
import tomli
from invoke import task
@task
def docs(ctx):
docs = Path(__file__).parent / "docs"
cli = docs / "cli.md"
commands = [
"--help",
"add --help",
"run --help",
]
lines = [
"This is the raw help text for the command line interface.",
]
for command in commands:
output = ctx.run(f"cargo run -- {command}")
lines.append("")
lines.append(f"## `{command}`")
lines.append("```")
for line in output.stdout.splitlines():
lines.append(line.rstrip())
lines.append("```")
if not docs.exists():
docs.mkdir()
cli.unlink()
with cli.open("a") as f:
for line in lines:
f.write(line + "\n")
@task
def release(ctx):
dist = Path("dist")
if dist.exists():
shutil.rmtree(dist)
dist.mkdir()
# Make sure that the lock file has the new version
ctx.run("cargo build")
docs(ctx)
manifest = Path("Cargo.toml")
version = tomli.loads(manifest.read_bytes().decode("utf-8"))["package"]["version"]
ctx.run(f"cargo lichking bundle --file dist/shawl-v{version}-legal.txt")