Repository: comonicon/Comonicon.jl (julia)

Issue:
[Feature Request] Support auto in nthreads
At the moment, the `nthreads` key in the `[install]` section of the `Comonicon.toml` file only support integers as values. However Julia is able to determine automatically the number of threads to spawn using the option `--threads=auto`, based on the number of available CPUs. This is useful for example on HPC clusters, where the number of allocated CPUs on each node can vary from one job to another.

Pull request description:
fix #198

Patch:
diff --git a/src/builder/install.jl b/src/builder/install.jl
index 2ae8021..45c47ac 100644
--- a/src/builder/install.jl
+++ b/src/builder/install.jl
@@ -102,7 +102,7 @@ function entryfile_script(m::Module, options::Configs.Comonicon)
         push!(cmds, "--sysimage=" * dylib)
     end
 
-    if options.install.nthreads > 1
+    if options.install.nthreads > 1 || options.install.nthreads == "auto"
         push!(cmds, string("--threads=", options.install.nthreads))
     end
 
diff --git a/src/configs.jl b/src/configs.jl
index 4de8bda..bb0b52a 100644
--- a/src/configs.jl
+++ b/src/configs.jl
@@ -60,6 +60,7 @@ Installation configurations.
 - `quiet`: print logs or not, default is `false`.
 - `compile`: julia compiler option for CLIs if not built as standalone application, default is "min".
 - `optimize`: julia compiler option for CLIs if not built as standalone application, default is `2`.
+- `nthreads`: julia compiler option for CLIs if not built as standalone application, default is `1`.
 """
 @option struct Install
     path::String = "~/.julia"
@@ -67,7 +68,7 @@ Installation configurations.
     quiet::Bool = false
     compile::String = "yes"
     optimize::Int = 2
-    nthreads::Int = 1
+    nthreads::Union{Int, String} = 1
 end
 
 """


Test patch:
diff --git a/test/Comonicon.toml b/test/Comonicon.toml
index 23badfc..69f802b 100644
--- a/test/Comonicon.toml
+++ b/test/Comonicon.toml
@@ -5,6 +5,7 @@ completion=true
 quiet=false
 compile="min"
 optimize=2
+nthreads="auto"
 
 [sysimg]
 path="deps"
diff --git a/test/options.jl b/test/options.jl
index 8072ed0..b8773af 100644
--- a/test/options.jl
+++ b/test/options.jl
@@ -7,7 +7,7 @@ using Comonicon.Configs
     display(options)
     @test options == Configs.Comonicon(;
         name = "foo",
-        install = Configs.Install(; compile = "min"),
+        install = Configs.Install(; compile = "min", nthreads="auto"),
         sysimg = Configs.SysImg(;
             cpu_target = "native",
             precompile = Configs.Precompile(; execution_file = ["deps/precopmile.jl"]),