Home / Docs / Configure a package
[run] entry
What it does
entry names the module whose main function una run and una build start: the first code of the program to run. main is pub main() -> Unit, and it receives host capabilities, the authority to use the console, files, the clock and the like that the runtime provides, through its uses clauses.
Learn more: The host's capabilities and grants.
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"
[run]
entry = "shop"
grants = ["console"]module shop
pub main() -> Unit
uses @console: Console[print]
=
@console.print("the shop is open")Forms
[run]
entry = "<module path>"The path of a module of the package, as its module line writes it: shop for src/shop.una, shop.orders for src/shop/orders.una.
Examples
An entry that names no module of the package is rejected:
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"
[run]
entry = "missing"
grants = ["console"]-- fails with U7002
module shop
pub price(cents: Int) -> Int = centsEdge cases
main takes host capabilities only. No grant can provide a capability that is not a host capability, so una check reports it:
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"
[run]
entry = "shop"
grants = ["console"]-- fails with U3012
module shop
pub capability Log
op write(line: Text) -> Unit
pub main() -> Unit
uses @log: Log[write]
=
@log.write("order 42 shipped")Further rules:
- Usage errors at run time. A package without an entry, or an entry without
pub main() -> Unit, makesuna runstop with a usage error, exit code 2. - A single file runs its own module, as if it were the entry.
- Grants. See
[run] grants.
Diagnostics
- U3012: a
usesof the entry'smainthat no grant can provide, or that the grants do not allow. - U7002: an entry that is not a module of the package.
Edition
entry is the same in editions 0.1 and 0.2. From edition 0.4 it is written in the run section of ita.una, as entry <module> (see ita.una).
Normative source
- spec/13 §7:
[run]; spec/13 §5:una runanduna build. - spec/04 §8: the entry point; spec/05 §7: host capabilities.