main.bend
ezx@1.3.0.0 · 79 lines · 0 definitions
1# ezx: ez's ledger library for Bend 2: it parses an ez.toml into its package, dependencies and pinned tools.
2#
3# main: the library's entry, which the hub publishes as ezx. It names the
4# reading ledger/manifest.bend does, one def each, so a program can read a
5# ledger by importing this file alone; the types the answers come in are
6# ledger/manifest.bend's, and a program that takes one apart imports that
7# file too. It sits at the top of the repo so the LICENSE beside it goes
8# along with the package. The ez binary is ez/main.bend, which ez.toml names
9# as `bin`.
10import Base
11import ezx@1.3.0.0/ledger/manifest.bend as M
12
13# an ez.toml's text read as a ledger, or why it could not be
14def parse(text: String) -> M.Read:
15 M.parse(text)
16
17# a ledger, or the error, on one line
18def show(ledger: M.Read) -> String:
19 M.show(ledger)
20
21# the named dependency of a ledger, or one with empty fields
22def dep(ledger: M.Read, name: String) -> M.Dep:
23 M.dep(ledger, name)
24
25# a dependency's own name
26def dep.name(dependency: M.Dep) -> String:
27 M.dep.name(dependency)
28
29# a dependency's hash, the `0x` name its import line carries
30def dep.hash(dependency: M.Dep) -> String:
31 M.dep.hash(dependency)
32
33# the file inside the package a dependency was added by
34def dep.entry(dependency: M.Dep) -> String:
35 M.dep.entry(dependency)
36
37# where a dependency's bytes come from
38def dep.source(dependency: M.Dep) -> M.Source:
39 M.source.dep(dependency)
40
41# the commit a source is pinned to, or "" for a hub package
42def source.rev(src: M.Source) -> String:
43 M.source.rev(src)
44
45# the tag a source was asked for, or "" when it was pinned by commit
46def source.tag(src: M.Source) -> String:
47 M.source.tag(src)
48
49# the repo a source is taken from, or "" for a hub package
50def source.url(src: M.Source) -> String:
51 M.source.url(src)
52
53# the `<name>@<version>` a hub source was added by, or ""
54def source.nv(src: M.Source) -> String:
55 M.source.nv(src)
56
57# whether a source names a repo rather than the hub
58def source.is_git(src: M.Source) -> Bool:
59 M.source.is_git(src)
60
61# the commit the named dependency is pinned to
62def rev_of(ledger: M.Read, name: String) -> String:
63 M.rev_of(ledger, name)
64
65# the tag the named dependency was asked for
66def tag_of(ledger: M.Read, name: String) -> String:
67 M.tag_of(ledger, name)
68
69# the hub a ledger's packages come from
70def hub_of(ledger: M.Read) -> String:
71 M.hub_of(ledger)
72
73# the pinned CLIs of a ledger
74def tools_of(ledger: M.Read) -> List<&2, M.Tool>:
75 M.tools_of(ledger)
76
77# a tool's own name
78def tool.name(pin: M.Tool) -> String:
79 M.tool.name(pin)