Skip to content

Latest commit

 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ocaml-cli

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.

Tools

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

Requirements

  • OCaml ≥ 5.3 (see dune-project)
  • opam and Dune
  • Dependencies: cmdliner; for tests: alcotest, bos
opam install . --deps-only --with-test

Build & run

dune build @install
dune exec echor -- Hello world
dune exec catr -- path/to/file

Tests

OCaml integration tests (test/)

Alcotest + 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 suite

echor 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.

Rust test harness (test-harness/)

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.

Layout

bin/<tool>/          # Cmdliner executables
test/<tool>/         # Alcotest + Bos integration tests
test/cli_test/       # shared test helpers
test-harness/        # Rust harness (reference)

License

See LICENSE / dune-project.

About

Learning ocaml with command line rust book

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages