OCaml ports of the CLI tools from Command-Line Rust (Ken Youens-Clark). The goal is to learn OCaml by reimplementing the book’s exercises with Cmdliner and Dune.
| Binary | Status | Notes |
|---|---|---|
echor |
Implemented | echo |
catr |
Implemented | cat |
headr |
Implemented (partial vs tests) | head |
wcr |
Stub (hello world) |
wc |
uniqr |
Stub | uniq |
findr |
Stub | find |
cutr |
Stub | cut |
grepr |
Stub | grep |
commr |
Stub | comm |
tailr |
Stub | tail |
fortuner |
Stub | fortune |
calr |
Stub | cal |
lsr |
Stub | ls |
- OCaml ≥ 5.3 (see
dune-project) - opam and Dune
- Dependencies:
cmdliner; for tests:alcotest,bos
opam install . --deps-only --with-testdune build @install
dune exec echor -- Hello world
dune exec catr -- path/to/fileAlcotest + Bos suites under test/, one directory per tool (fixtures in inputs/ / expected/). Shared helpers live in test/cli_test/.
These OCaml tests were created by Cursor (Auto), ported from the book’s Rust CLI tests into this repo’s Alcotest layout.
dune runtest # all suites
dune runtest test/echor # one suiteechor and catr are expected to pass. Suites for stub binaries will fail until those tools are implemented. headr has known failures vs the harness expectations.
Optional mirror of the book’s assert_cmd tests, adapted to run dune exec <tool> -- …:
just test # or: just test echor::Requires a Rust toolchain. Useful for comparing behavior while porting.
bin/<tool>/ # Cmdliner executables
test/<tool>/ # Alcotest + Bos integration tests
test/cli_test/ # shared test helpers
test-harness/ # Rust harness (reference)
See LICENSE / dune-project.