Entry points
Where a Faber program starts.
The ordinary entry point#
main — "it begins". No parameters, no return type.
faber format --locale en — English reader surfacemain {
print "Salve, munde!"
}faber format --locale la — canonical Faberincipit {
nota "Salve, munde!"
}faber format --locale th-TH — Thaiเริ่ม {
บันทึก "Salve, munde!"
}faber format --locale zh-Hans — Simplified Chinese入口 {
显示 "Salve, munde!"
}faber format --locale zh-Hant — Traditional Chinese入口 {
註記 "Salve, munde!"
}faber format --locale vi — Vietnamesebắt_đầu {
ghi_chú "Salve, munde!"
}faber format --locale ar — Arabicبداية {
اعرض "Salve, munde!"
}faber format --locale hi — Hindiआरंभ {
दिखाओ "Salve, munde!"
}Async entry point#
incipiet — "it will begin". Use it when the program awaits anything.
faber format --locale en — English reader surfaceasync_main {
print "async ready"
}faber format --locale la — canonical Faberincipiet {
nota "async ready"
}faber format --locale th-TH — Thaiเริ่มอะซิงก์ {
บันทึก "async ready"
}faber format --locale zh-Hans — Simplified Chinese异步入口 {
显示 "async ready"
}faber format --locale zh-Hant — Traditional Chinese非同步入口 {
註記 "async ready"
}faber format --locale vi — Vietnamesebắt_đầu_bất_đồng_bộ {
ghi_chú "async ready"
}faber format --locale ar — Arabicاستهلال {
اعرض "async ready"
}faber format --locale 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 format --locale en — English reader surfacemain args args {
print "started"
}faber format --locale la — canonical Faberincipit argumenta args {
nota "started"
}faber format --locale th-TH — Thaiเริ่ม อาร์กิวเมนต์ args {
บันทึก "started"
}faber format --locale zh-Hans — Simplified Chinese入口 参数 args {
显示 "started"
}faber format --locale zh-Hant — Traditional Chinese入口 引數 args {
註記 "started"
}faber format --locale vi — Vietnamesebắt_đầu đối_số args {
ghi_chú "started"
}faber format --locale ar — Arabicبداية وسائط args {
اعرض "started"
}faber format --locale hi — Hindiआरंभ तर्क args {
दिखाओ "started"
}Naming the command#
The @ cli annotation names the binary the package produces.
faber format --locale en — English reader surface@ cli { name = "salve" }
main args args {
print "started"
}faber format --locale la — canonical Faber@ cli { nomen = "salve" }
incipit argumenta args {
nota "started"
}faber format --locale th-TH — Thai@ cli { ชื่อ = "salve" }
เริ่ม อาร์กิวเมนต์ args {
บันทึก "started"
}faber format --locale zh-Hans — Simplified Chinese@ 命令行 { 名称 = "salve" }
入口 参数 args {
显示 "started"
}faber format --locale zh-Hant — Traditional Chinese@ 命令行 { 名稱 = "salve" }
入口 引數 args {
註記 "started"
}faber format --locale vi — Vietnamese@ cli { tên = "salve" }
bắt_đầu đối_số args {
ghi_chú "started"
}faber format --locale ar — Arabic@ cli { اسم = "salve" }
بداية وسائط args {
اعرض "started"
}faber format --locale hi — Hindi@ cli { नाम = "salve" }
आरंभ तर्क args {
दिखाओ "started"
}Declaring options#
@ optio declares one command-line option. Repeat it for each. The binding
name comes first, then keyword-introduced fields — no braces, no commas.
faber format --locale en — English reader surface@ cli { name = "salve" }
@ option { binding = nomen, 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"
}faber format --locale la — canonical Faber@ cli { nomen = "salve" }
@ optio { binding = nomen, brevis = "n", longum = "nomen", typus = textus, descriptio = "who to greet" }
@ optio { binding = quotiens, longum = "quotiens", typus = numerus, descriptio = "how many times" }
incipit argumenta args {
nota "started"
}faber format --locale th-TH — Thai@ cli { ชื่อ = "salve" }
@ ตัวเลือก { binding = nomen, สั้น = "n", ยาว = "nomen", ชนิดนามแฝง = ข้อความ, คำอธิบาย = "who to greet" }
@ ตัวเลือก { binding = quotiens, ยาว = "quotiens", ชนิดนามแฝง = จำนวน, คำอธิบาย = "how many times" }
เริ่ม อาร์กิวเมนต์ args {
บันทึก "started"
}faber format --locale zh-Hans — Simplified Chinese@ 命令行 { 名称 = "salve" }
@ 选项 { binding = nomen, 简 = "n", 详 = "nomen", 类型 = 文本, 描述 = "who to greet" }
@ 选项 { binding = quotiens, 详 = "quotiens", 类型 = 整数, 描述 = "how many times" }
入口 参数 args {
显示 "started"
}faber format --locale zh-Hant — Traditional Chinese@ 命令行 { 名稱 = "salve" }
@ 選項 { binding = nomen, 簡 = "n", 詳 = "nomen", 型別 = 文字, 描述 = "who to greet" }
@ 選項 { binding = quotiens, 詳 = "quotiens", 型別 = 整數, 描述 = "how many times" }
入口 引數 args {
註記 "started"
}faber format --locale vi — Vietnamese@ cli { tên = "salve" }
@ tùy_chọn { binding = nomen, ngắn = "n", dài = "nomen", kiểu_tên = văn_bản, mô_tả = "who to greet" }
@ tùy_chọn { binding = quotiens, dài = "quotiens", kiểu_tên = số, mô_tả = "how many times" }
bắt_đầu đối_số args {
ghi_chú "started"
}faber format --locale ar — Arabic@ cli { اسم = "salve" }
@ خيار { binding = nomen, مختصر = "n", مفصل = "nomen", نمط = نص, وصف = "who to greet" }
@ خيار { binding = quotiens, مفصل = "quotiens", نمط = عدد, وصف = "how many times" }
بداية وسائط args {
اعرض "started"
}faber format --locale hi — Hindi@ cli { नाम = "salve" }
@ विकल्प { binding = nomen, संक्षिप्त = "n", विस्तृत = "nomen", प्रकार = पाठ, विवरण = "who to greet" }
@ विकल्प { binding = quotiens, विस्तृत = "quotiens", प्रकार = संख्या, विवरण = "how many times" }
आरंभ तर्क args {
दिखाओ "started"
}| Field | Purpose |
|---|---|
| (first word) | The name the parsed value binds to |
brevis | Short flag, as in -n |
longum | Long flag, as in --nomen |
typus | The option's type |
descriptio | Help text |
ubique | Accept the option on every subcommand |
An option can declare longum without brevis, as quotiens does above.
Related: Commands for running what you build, and Your first package for the surrounding package layout.