How do you use Comonicon.jl?

I am very confused by the instructions here 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.

1 Like

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

name = "my-cli"

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

In deps/build.jl put

using Comonicon, MyPackage
Comonicon.install(MyPackage)

Then in src/MyPackage.jl

module ContainerCLI

using Comonicon, Pkg.TOML, SimpleContainerGenerator, Logging

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

end # module
2 Likes

How do I call this in the bash?

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

2 Likes