# CLI for processing files using Elm functions

**URL:** <https://discourse.elm-lang.org/t/cli-for-processing-files-using-elm-functions/10949>\
**Category:** Show and Tell\
**Created:** [October 25, 2026, 2:01pm UTC](https://discourse.elm-lang.org/t/cli-for-processing-files-using-elm-functions/10949 "2026-10-25T14:01:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Viir](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/viir/32/4103_2.png) [@Viir](https://discourse.elm-lang.org/u/Viir)\
**Post date:** [October 25, 2026, 2:01pm UTC](https://discourse.elm-lang.org/t/cli-for-processing-files-using-elm-functions/10949/1 "2026-10-25T14:01:37Z")

</div>

I toyed around with a command line interface to run Elm functions directly, including support for files as inputs and outputs.

Following is the current state of the interface:

- Required argument on the CLI command is a path to an Elm module containing the function, or even further a specific declaration (syntax using slash inside Elm module or line number)
- `--input` option to add an additional argument value inline (parsed as Elm expression / structural typing also for choice types)
- `--input-file` option to add an additional argument from a file content.
- `--output-file` to save the return value from the Elm function.
- `--watch`: Live update when input files change.

When connected to a terminal, it shows an interactive prompt to select a function declaration (In case the given context only points to a whole Elm module):

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/2X/2/20839512ee37015c4b126993132049790f558533.png)

After selecting a function declaration, it prompts for remaining argument values, if not all were given with `--input` options:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/2X/5/53b66d7f142de696698e3ab4765b9d6e501e0bea.png)

If no output file is specified, the CLI prints the return value in the terminal:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/2X/1/114c9c699c07780cc0f609f8ebbf9087557ca8be.png)

### Watch Mode

This video shows the use of the `--watch` mode specifically, with one file as input and one file as output:

[![](https://img.youtube.com/vi/6kmOBL_xGEM/maxresdefault.jpg "Save. See it change. — Elm batch processing gets a --watch mode") ](https://www.youtube.com/watch?v=6kmOBL_xGEM)

---

<div class="post-metadata">

**Author:** ![Viir](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/viir/32/4103_2.png) [@Viir](https://discourse.elm-lang.org/u/Viir)\
**Post date:** [October 25, 2026, 4:13pm UTC](https://discourse.elm-lang.org/t/cli-for-processing-files-using-elm-functions/10949/2 "2026-10-25T16:13:33Z")

</div>

I added a more extensive exploration at [https://github.com/Viir/explore-processing/blob/main/apply-svg-demos/README.md](https://github.com/Viir/explore-processing/blob/main/apply-svg-demos/README.md)

---

<div class="post-metadata">

**Author:** ![wolfadex](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/wolfadex/32/2461_2.png) [@wolfadex](https://discourse.elm-lang.org/u/wolfadex)\
**Post date:** [October 25, 2026, 4:18pm UTC](https://discourse.elm-lang.org/t/cli-for-processing-files-using-elm-functions/10949/3 "2026-10-25T16:18:57Z")

</div>

This is really interesting!! Are you using it for anything or just exploring?

---

<div class="post-metadata">

**Author:** ![Viir](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/viir/32/4103_2.png) [@Viir](https://discourse.elm-lang.org/u/Viir)\
**Post date:** [October 25, 2026, 4:45pm UTC](https://discourse.elm-lang.org/t/cli-for-processing-files-using-elm-functions/10949/4 "2026-10-25T16:45:38Z")

</div>

Just exploring so far. Its more been a recreational activity, I wanted to do something else for once.

One influence motivating me for this “apply” command was seeing how often GitHub copilot / Claude Code reach for python scripts, only to transform some files.  
Using pure functions for in such tool calls would be much better.  
For use cases like such file edits and bulk file edits, I am thinking of expanding the input/output model to support file trees / directories.
