Renderingen-US

Entry points

Where a Faber program starts.

The ordinary entry point#

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

reader locale
faber format --locale en — English reader surface
main {
    print "Salve, munde!"
}
faber format --locale la — canonical Faber
incipit {
    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 — Vietnamese
bắ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.

reader locale
faber format --locale en — English reader surface
async_main {
    print "async ready"
}
faber format --locale la — canonical Faber
incipiet {
    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 — Vietnamese
bắ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.

reader locale
faber format --locale en — English reader surface
main args args {
    print "started"
}
faber format --locale la — canonical Faber
incipit 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 — Vietnamese
bắ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.

reader locale
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.

reader locale
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"
}
FieldPurpose
(first word)The name the parsed value binds to
brevisShort flag, as in -n
longumLong flag, as in --nomen
typusThe option's type
descriptioHelp text
ubiqueAccept 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.