# How do you use Comonicon.jl?

**URL:** https://discourse.julialang.org/t/how-do-you-use-comonicon-jl/45024
**Category:** New to Julia
**Created:** [August 16, 2020, 6:01am UTC](https://discourse.julialang.org/t/how-do-you-use-comonicon-jl/45024 "2020-08-16T06:01:46Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)
#### Post date: [August 16, 2020, 6:01am UTC](https://discourse.julialang.org/t/how-do-you-use-comonicon-jl/45024/1 "2020-08-16T06:01:46Z")

</div>

I am very confused by the instructions here [https://rogerluo.me/Comonicon.jl/](https://rogerluo.me/Comonicon.jl/)

I thought the Getting started should read

1. Put these code into a Julia file.jl
2. Run this some other code
3. In bash run this other code; see that’s how it works

But after reading getting starts, I still don’t understand how to use it. Can someone please help me? Preferably in an idiot guides way in the steps 1-3 above. I think he page currently has 1 but not 2 and 3.

---

<div class="post-metadata">

### Author: ![onetonfoot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/onetonfoot/32/2697_2.png) [@onetonfoot](https://discourse.julialang.org/u/onetonfoot)
#### Post date: [August 19, 2020, 9:22am UTC](https://discourse.julialang.org/t/how-do-you-use-comonicon-jl/45024/2 "2020-08-19T09:22:32Z")

</div>

Create a new package. Then in the root put your options in a file called `Comonicon.toml`

```julia
name = "my-cli"

[install]
export_path=true
completion=true
quiet=false
compile="min"
optimize=2

```

In `deps/build.jl` put

```julia
using Comonicon, MyPackage
Comonicon.install(MyPackage)

```

Then in `src/MyPackage.jl`

```julia
module ContainerCLI

using Comonicon, Pkg.TOML, SimpleContainerGenerator, Logging

@main function my_cli(x::String)
   print("Hello from my cli $x")
end

end # module

```

---

<div class="post-metadata">

### Author: ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)
#### Post date: [August 19, 2020, 9:32am UTC](https://discourse.julialang.org/t/how-do-you-use-comonicon-jl/45024/3 "2020-08-19T09:32:38Z")

</div>

How do I call this in the bash?

---

<div class="post-metadata">

### Author: ![onetonfoot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/onetonfoot/32/2697_2.png) [@onetonfoot](https://discourse.julialang.org/u/onetonfoot)
#### Post date: [August 19, 2020, 9:38am UTC](https://discourse.julialang.org/t/how-do-you-use-comonicon-jl/45024/4 "2020-08-19T09:38:32Z")

</div>

The `name` in the `Comonicon.toml` should be available in bash so in this case  
`my-cli --help`. The first time during development you might have to run `]build` to get it to work

---

<div class="post-metadata">

### Author: ![xoth42](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xoth42/32/217623_2.png) [@xoth42](https://discourse.julialang.org/u/xoth42)
#### Post date: [July 8, 2025, 12:27am UTC](https://discourse.julialang.org/t/how-do-you-use-comonicon-jl/45024/5 "2025-07-08T00:27:41Z")

</div>

This thread really helped me, and I think this is a great tool, so I figured I might as well add a bit and bring it up to date.

The original link that was posted for Comonicon.jl is now dead, but the github is there and there are docs for it. The quick setup is more or less the same, although `Comonicon.toml` no longer takes `export_path=true`, so it would now look like:

```julia
name = "my-cli"

[install]
completion=true
quiet=false
compile="min"
optimize=2

```

Although most of the options are not necessary, and it works with only

```julia
name = "my-cli"

[install]

```

And another small change is that `deps/build.jl` now looks like

```julia
using MyPackage
MyPackage.comonicon_install()

```

An example for `src/MyPackage.jl`:

```julia
module MyPackage

using Comonicon

@Comonicon.main function my_cli(x::String)
   println("Hello from my cli $x")
end

end

```

You can then run `]build` in the REPL and your executable should appear in `~/.julia/bin/`.

You can also use the Comonicon project setup mentioned in the docs, which will have you use the old but working IonCLI.jl project, now moved to Ion. Ion actually does not have the template for Comonicon, so stick to IonCLI. If your are doing so, also make sure to set your git user config (user.name and user.email), as well as JULIA\_EXECUTABLE\_PATH or you will get errors.
