Renderingen-US

Entry points

Where a Faber program starts.

The ordinary entry point#

main — "it begins". No parameters, no return type.

reader locale
faber convert --to en — English reader surface
main {
    print "Salve, munde!"
}
faber convert --to la — canonical Faber
incipit {
    nota "Salve, munde!"
}
faber convert --to th-TH — Thai
เริ่ม {
    บันทึก "Salve, munde!"
}
faber convert --to zh-Hans — Simplified Chinese
入口 {
    显示 "Salve, munde!"
}
faber convert --to zh-Hant — Traditional Chinese
入口 {
    註記 "Salve, munde!"
}
faber convert --to vi — Vietnamese
bắt_đầu {
    ghi_chú "Salve, munde!"
}
faber convert --to ar — Arabic
بداية {
    اعرض "Salve, munde!"
}
faber convert --to hi — Hindi
आरंभ {
    दिखाओ "Salve, munde!"
}

Async entry point#

async_main — "it will begin". Use it when the program awaits anything.

reader locale
faber convert --to en — English reader surface
async_main {
    print "async ready"
}
faber convert --to la — canonical Faber
incipiet {
    nota "async ready"
}
faber convert --to th-TH — Thai
เริ่มอะซิงก์ {
    บันทึก "async ready"
}
faber convert --to zh-Hans — Simplified Chinese
异步入口 {
    显示 "async ready"
}
faber convert --to zh-Hant — Traditional Chinese
非同步入口 {
    註記 "async ready"
}
faber convert --to vi — Vietnamese
bắt_đầu_bất_đồng_bộ {
    ghi_chú "async ready"
}
faber convert --to ar — Arabic
استهلال {
    اعرض "async ready"
}
faber convert --to hi — Hindi
आरंभasync {
    दिखाओ "async ready"
}

The two are alternatives, not a pair: a program declares one or the other.

Command-line arguments#

args binds the parsed argument object.

reader locale
faber convert --to en — English reader surface
main args args {
    print "started"
}
faber convert --to la — canonical Faber
incipit argumenta args {
    nota "started"
}
faber convert --to th-TH — Thai
เริ่ม อาร์กิวเมนต์ args {
    บันทึก "started"
}
faber convert --to zh-Hans — Simplified Chinese
入口 参数 args {
    显示 "started"
}
faber convert --to zh-Hant — Traditional Chinese
入口 引數 args {
    註記 "started"
}
faber convert --to vi — Vietnamese
bắt_đầu đối_số args {
    ghi_chú "started"
}
faber convert --to ar — Arabic
بداية وسائط args {
    اعرض "started"
}
faber convert --to hi — Hindi
आरंभ तर्क args {
    दिखाओ "started"
}

Naming the command#

The @ cli annotation names the binary the package produces.

reader locale
faber convert --to en — English reader surface
@ cli { name = "salve" }
main args args {
    print "started"
}
faber convert --to la — canonical Faber
@ cli { nomen = "salve" }
incipit argumenta args {
    nota "started"
}
faber convert --to th-TH — Thai
@ cli { ชื่อ = "salve" }
เริ่ม อาร์กิวเมนต์ args {
    บันทึก "started"
}
faber convert --to zh-Hans — Simplified Chinese
@ 命令行 { 名称 = "salve" }
入口 参数 args {
    显示 "started"
}
faber convert --to zh-Hant — Traditional Chinese
@ 命令行 { 名稱 = "salve" }
入口 引數 args {
    註記 "started"
}
faber convert --to vi — Vietnamese
@ cli { tên = "salve" }
bắt_đầu đối_số args {
    ghi_chú "started"
}
faber convert --to ar — Arabic
@ cli { اسم = "salve" }
بداية وسائط args {
    اعرض "started"
}
faber convert --to hi — Hindi
@ cli { नाम = "salve" }
आरंभ तर्क args {
    दिखाओ "started"
}

Declaring options#

@ option declares one command-line option. Repeat it for each. The binding name comes first, then keyword-introduced fields — no braces, no commas.

@ cli { name = "salve" }
@ option { binding = name, short = "n", long = "nomen", type = string, description = "who to greet" }
@ option { binding = quotiens, long = "quotiens", type = int, description = "how many times" }
main args args {
    print "started"
}
FieldPurpose
(first word)The name the parsed value binds to
shortShort flag, as in -n
longLong flag, as in --nomen
typeThe option's type
descriptionHelp text
globalAccept the option on every subcommand

An option can declare long without short, as quotiens does above.

Related: Commands for running what you build, and A program is a package for the surrounding package layout.