DUNE-INIT(1)

πŸ¦‹ DUNE-INIT(1) β€” bestie edition

okay so. you're looking at dune-init from the Dune Manual, and honestly? it's giving project scaffolding main character energy. it's the command group that initializes Dune components. that's it. that's the job. and it does it flawlessly, no cap. πŸ’…


✨ NAME ✨

dune-init β€” the command group for initializing Dune components, periodt.


🌸 SYNOPSIS 🌸

dune init project NAME [PATH] [OPTION]...
dune init executable NAME [PATH] [OPTION]...
dune init library NAME [PATH] [OPTION]...
dune init test NAME [PATH] [OPTION]...
dune init start-file [PATH]

πŸ’– DESCRIPTION πŸ’–

So here's the vibe. When you run:

dune init COMPONENT NAME [PATH] [OPTION]...

…it initializes a brand new dune configuration for a component. The kind of component is whatever the subcommand COMPONENT says it is, it's named NAME, and its fields get filled in based on the OPTIONs you hand it. that's literally the whole deal.

Want the tea on any one subcommand? Run it with --help and it'll spill the details on its supported arguments. πŸ«–

Now, the optional PATH β€” if you give one, it must be a path to a directory, because that's where the component gets created. If you don't give one, it gets created in a child of the current working directory, and that child is called NAME. And if you wanna init a component in the current working directory itself? Use . as the PATH. iconic behavior, honestly.

Also super cute: any prefix of a COMMAND's name works in place of the full name. yes bestie, shortcuts are built in (it's illustrated up in the synopsis if you wanna peek).

For more deets, go read https://dune.readthedocs.io/en/stable/usage.html#initializing-components 🌈


πŸ‘‘ COMMANDS πŸ‘‘

  • executable [OPTION]… NAME [PATH] β€” a binary executable. that's what it is. a program. she runs.
  • library [OPTION]… NAME [PATH] β€” an OCaml library. for when you have reusable code and you want everyone to know about it.
  • project [OPTION]… NAME [PATH] β€” a project is a predefined composition of components arranged in a standard directory structure. the kind of project you get is decided by the value of the --kind flag, and it defaults to an executable project β€” which is itself composed of a library, an executable, and a test component. it's a whole little ecosystem, a full outfit. πŸ’ƒ
  • start-file [OPTION]… [PATH] β€” writes the standard start/dune file. that's the whole job and she does it well.
  • test [OPTION]… NAME [PATH] β€” a test harness. and psst, for inline tests you use the --inline-tests flag along with the other component kinds. πŸ§ͺ

πŸ’… COMMON OPTIONS πŸ’…

  • --help[=FMT] (default=auto) β€” shows this help in format FMT. FMT has to be one of auto, pager, groff or plain. with auto, the format is pager or plain whenever the TERM env var is dumb or undefined. yes, it checks. she's considerate like that.
  • --version β€” shows version information. the classic.

πŸ”₯ EXIT STATUS πŸ”₯

dune init exits with:

  1. 0 β€” on success. slay. πŸ’–
  2. 1 β€” if an error happened. 😭
  3. 130 β€” if it was interrupted by a signal. πŸ’€

🌈 EXAMPLES 🌈

  1. Generate a project skeleton for an executable named myproj in a new directory named myproj, depending on the bos library and using inline tests along with ppx_inline_test:
dune init project myproj --libs bos --ppx ppx_inline_test --inline-tests
  1. Configure an executable component named myexe in a dune file in the current directory:
dune init executable myexe
  1. Configure a library component named mylib in a dune file in the ./src directory depending on the core and cmdliner libraries, the ppx_let and ppx_inline_test preprocessors, and declared as using inline tests:
dune init library mylib src --libs core,cmdliner --ppx ppx_let,ppx_inline_test --inline-tests
  1. Configure a test component named mytest in a dune file in the ./test directory that depends on mylib:
dune init test mytest test --libs mylib
  1. Write the standard start/dune helper file:
dune init start-file

πŸŽ€ SEE ALSO πŸŽ€

  • dune(1) β€” go say hi to the main page bestie, she knows everything. 🫢

and that's the whole page, loves! this was Dune 3.24.1, and yes, it's giving iconic. go forth and dune init something cute. πŸ’œβœ¨

πŸ“¦ where this page comes from