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.
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
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
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:
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
name = "my-cli"
[install]
And another small change is that deps/build.jl now looks like
using MyPackage
MyPackage.comonicon_install()
An example for src/MyPackage.jl:
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.