Although I still have a lot feature want to add to it, I think it’s time to announce this and let people try it since I have been making whoever I know to try it in past few weeks. Thus I’m announcing a new CLI package IonCLI.jl. It’s still at an early stage, even I have tested it myself in daily usage for a few weeks, I still expect it to have some glitches, and please file an issue to help improve it if you hit any.
IonCLI is a CLI command made for managing Julia packages: most of its commands are the same as Pkg and forwards the arguments you type in terminal to Julia’s package manager Pkg.
a glance at its help
But it also provides some extra commands to make your life easier as a developer:
release
you can directly release a new version of your package from terminal, the IonCLI will automatically:
- ask if you want to bump your package version according to one of
patch, minor, major
or a given version, ifY/y
orenter
then change it - commit this change to your git repo and push it
- create the comment
@JuliaRegistrator register
at this commit
all in one command, e.g type the following in your package directory
ion release patch
will prompt as following
then if you press enter, it will continue to release a new patch version, if you don’t have an environment variable GITHUB_AUTH
that contains your github token, it will prompt to ask you to type one.
and you can click the link it returns to see your comment, which for this case is
create
Sometimes you just have a few fixed templates and you just want to create using those templates using only one command, and this is possible with IonCLI’s create command, you can create a new package via PkgTemplates using
➜ julia_code ion create MyCLIPackage --template comonicon --user Roger-luo
[ Info: Running prehooks
[ Info: Running hooks
Activating environment at `~/julia_code/MyCLIPackage/Project.toml`
Updating registry at `~/.julia/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Updating registry at `~/.julia/registries/Miskatonic`
Updating git-repo `https://github.com/Happy-Diode/Miskatonic.git`
┌ Warning: Some registries failed to update:
│ — /Users/roger/.julia/registries/General — failed to fetch from repo
│ — /Users/roger/.julia/registries/Miskatonic — failed to fetch from repo
└ @ Pkg.Types /Users/runner/hostedtoolcache/julia/1.5.0/x64/share/julia/stdlib/v1.5/Pkg/src/Types.jl:1194
No Changes to `~/julia_code/MyCLIPackage/Project.toml`
No Changes to `~/julia_code/MyCLIPackage/Manifest.toml`
Activating environment at `~/.julia/packages/IonCLI/2bIDV/Project.toml`
[ Info: Running posthooks
[ Info: New package is at /Users/roger/julia_code/MyCLIPackage
(fuzzy) search
sometimes you just don’t remember the exact name, don’t worry, you don’t have to move to your mouse and open your browser and type some words in a search engine, you can just do it in your terminal!
and the word to search doesn’t have to be exact or first few letters, it’s fuzzy
But with all these complicated features, I guess all you want to ask might be: isn’t this gonna be slow? given Julia has the latency issue at this moment. Do I have to compile a system image locally myself?
No. IonCLI builds a system image using GitHub Actions, it will try to download the tarball directly instead of waiting for PackageCompiler to compile every time you install/upgrade it locally. And since it’s compiled and executed using compile=min
, the startup time of IonCLI is around the julia compiler’s startup time, which on my desktop with a Ryzen 3900X CPU, is about 80ms.
Differences between IonCLI and jlpkg
IonCLI does not simply forward the command to Julia’s package mode, thus you might find the workflow and commands is a bit different from using jlpkg
or package mode:
- all the commands by default are executed in current local project environment
- all the commands that needs to be executed in global shared environment need to be specified by
-g, --glob
flag
the reason is in terminal unlike REPL, you always cd
to your project to use other tools, thus like many other languages’ command line manager, it will use the local project as prior.
IonCLI as the best practice of Comonicon
You might have noticed my previous release on this CLI generator: Comonicon.jl - Fast, Simple and Light weight CLI generator
and yes, IonCLI is made by Comonicon
, thus all the shell command syntax of IonCLI
follows the design of Comonicon
, it limits some shell features, but I believe it makes all the commands made by Comonicon to follow a unified flavor.
If you want to make your own CLI package, you can also take IonCLI as a reference for sure!
Simple Implementation and extensibility
Since it’s generated by Comonicon, it does not handle shell commands by itself at all, you can even just use IonCLI
as a normal package, and extend it by overloading it’s functions.
Shell Auto-Completion
currently, ion
supports shell autocompletion for zsh
and it is generated automatically by Comonicon. But if you know how to do autocompletion for other shells please help and contribute!
Future Plans
The idea of IonCLI is to free you from pressing too much buttons in some common manage work. Thus there are still a few features I wanted personally but still missing:
- upgrade Julia compiler directly in terminal, something like jill.py but I think now it’s possible to do it in pure Julia
- better package search, current package search is still slow since it will send request to github for all possible match, it would be nice to have some meta info in the registry (e.g a package description), so it can directly search the local registry
- fully standalone binary, currently limited by PackageCompiler, the compiled redistributable binary is about 200MB, which is still quite large, but I’m looking forward to upcoming PackageCompiler improvements mentioned in JuliaCon2020 to reduce this.
I’m not sure what else you want, but now with PackageCompiler and Comonicon, we can build more complicated CLIs without worrying about the latency!