Entry points
Where a Faber program starts.
The ordinary entry point#
main — "it begins". No parameters, no return type.
faber convert --to en — English reader surfacemain {
print "Salve, munde!"
}faber convert --to la — canonical Faberincipit {
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 — Vietnamesebắ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.
faber convert --to en — English reader surfaceasync_main {
print "async ready"
}faber convert --to la — canonical Faberincipiet {
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 — Vietnamesebắ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.
faber convert --to en — English reader surfacemain args args {
print "started"
}faber convert --to la — canonical Faberincipit 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 — Vietnamesebắ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.
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"
}| Field | Purpose |
|---|---|
| (first word) | The name the parsed value binds to |
short | Short flag, as in -n |
long | Long flag, as in --nomen |
type | The option's type |
description | Help text |
global | Accept 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.