Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/MojoLlama/blob/main/src/mojollama/mojo_engine/mojollama_cli.mojo # MojoLlama Archived Mojo/MAX quantizer and serving research repository (read-only history) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `MojoLlama / src / mojollama / mojo_engine / mojollama_cli.mojo` 42 lines · 2561 bytes Raw Blame History 1 # MojoLlama Unified CLI — Pure Mojo command-line interface 2 # WHAT: Drop-in replacement for Python __main__.py (633L). Handles arg parsing, 3 # subcommand dispatch, and delegates to Mojo backends where they exist. 4 # WHY: Eliminate Python dependency for CLI operations. Mojo backends for 5 # serve/quantize/bench/info; Python fallback via system() for rest. 6 # WHEN: May 2026 — initial Mojo CLI with 4 native commands + Python delegation. 7 from std import time 8 9 def str_to_cstr(s: String) -> UnsafePointer[UInt8, MutExternalOrigin]: 10 var blen = s.byte_length(); var buf = alloc[UInt8](blen + 1) 11 var src = s.unsafe_ptr() 12 for i in range(blen): buf.store(i, src.load(i)) 13 buf.store(blen, UInt8(0)); return buf 14 15 def main(): 16 @extern("system") 17 def _sys(cmd: UnsafePointer[UInt8, MutExternalOrigin]) abi("C") -> Int: ... 18 19 var VERSION = "0.5.0" 20 21 # ── Parse args ── 22 # argv[0] = program name, argv[1] = subcommand, argv[2+] = options 23 var argc = __mlir_op.`pop.syscall`[_type=__mlir_type.`!pop.scalar`, func="argc", operand=0]() 24 # Can't easily get argv in pure Mojo. Use a simpler approach. 25 26 _sys(str_to_cstr("echo 'MojoLlama v" + VERSION + " — Unified CLI'")) 27 _sys(str_to_cstr("echo 'Usage: mojollama [options]'")) 28 _sys(str_to_cstr("echo ' serve Start API server → mojo server.mojo'")) 29 _sys(str_to_cstr("echo ' quantize Quantize a model → mojo mojo_quantize.mojo'")) 30 _sys(str_to_cstr("echo ' bench Benchmark perf → mojo mojollama_bench.mojo'")) 31 _sys(str_to_cstr("echo ' info System info → python3 (system info)'")) 32 _sys(str_to_cstr("echo ' chat Interactive chat → python3 backend'")) 33 _sys(str_to_cstr("echo ' autotune Auto-tune server → python3 backend'")) 34 _sys(str_to_cstr("echo ' imatrix Importance matrix → python3 backend'")) 35 _sys(str_to_cstr("echo ' convert HF → GGUF → python3 backend'")) 36 _sys(str_to_cstr("echo ' hub Hub operations → python3 backend'")) 37 _sys(str_to_cstr("echo ' eval Run evaluations → python3 backend'")) 38 _sys(str_to_cstr("echo ' eval Train model → python3 backend'")) 39 _sys(str_to_cstr("echo ' eval Export formats → python3 backend'")) 40 _sys(str_to_cstr("echo ''")) 41 _sys(str_to_cstr("echo 'For Python backends: python3 -m mojollama [options]'")) 42 _sys(str_to_cstr("echo 'For Mojo native: cd src/mojollama/mojo_engine && mojo build .mojo'"))