Repository: comonicon/Comonicon.jl
Pull request #223 (2022-08-22 01:31:27)

fix setting config from cli
This should fix combining `--config=<path>` with `--config.<property>=<value>`,
the shell auto-completion still won't work with the `dot` operator syntax tho

cc: @avik-pal 

codecov[bot]: # [Codecov](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
Base: **83.65**% // Head: **1.03**% // Decreases project coverage by **`-82.62%`** :warning:
> Coverage data is based on head [(`8e427e7`)](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) compared to base [(`b64242c`)](https://codecov.io/gh/comonicon/Comonicon.jl/commit/b64242c973598b8c099b083c1cec7d5d2134016e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).
> Patch coverage: 0.00% of modified lines in pull request are covered.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #223       +/-   ##
==========================================
- Coverage   83.65%   1.03%   -82.63%     
==========================================
  Files          21      20        -1     
  Lines        1585    1546       -39     
==========================================
- Hits         1326      16     -1310     
- Misses        259    1530     +1271     
```


| [Impacted Files](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | |
|---|---|---|
| [src/codegen/julia.jl](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2NvZGVnZW4vanVsaWEuamw=) | `0.00% <0.00%> (-88.86%)` | :arrow_down: |
| [src/compat.jl](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2NvbXBhdC5qbA==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [src/exceptions.jl](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2V4Y2VwdGlvbnMuamw=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [src/builder/app.jl](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2J1aWxkZXIvYXBwLmps) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [src/frontend/markdown.jl](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2Zyb250ZW5kL21hcmtkb3duLmps) | `0.00% <0.00%> (-94.49%)` | :arrow_down: |
| [src/builder/install.jl](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2J1aWxkZXIvaW5zdGFsbC5qbA==) | `0.00% <0.00%> (-93.25%)` | :arrow_down: |
| [src/codegen/zsh.jl](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2NvZGVnZW4venNoLmps) | `0.00% <0.00%> (-92.60%)` | :arrow_down: |
| [src/codegen/bash.jl](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2NvZGVnZW4vYmFzaC5qbA==) | `0.00% <0.00%> (-91.02%)` | :arrow_down: |
| [src/builder/cli.jl](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2J1aWxkZXIvY2xpLmps) | `0.00% <0.00%> (-89.71%)` | :arrow_down: |
| [src/ast/utils.jl](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2FzdC91dGlscy5qbA==) | `0.00% <0.00%> (-88.89%)` | :arrow_down: |
| ... and [11 more](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/comonicon/Comonicon.jl/pull/223?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).


Patch:
diff --git a/src/codegen/julia.jl b/src/codegen/julia.jl
index d2d457b..758a266 100644
--- a/src/codegen/julia.jl
+++ b/src/codegen/julia.jl
@@ -3,6 +3,7 @@ module JuliaExpr
 using ..AST
 using ..Comonicon: CommandException, CommandExit, _sprint
 using ExproniconLite
+using TOML: TOML
 using Configurations: Configurations
 
 function help_str(x; color = true, width::Int)
@@ -480,9 +481,7 @@ function emit_parse_value(cmd, ctx::EmitContext, type, value)
     elseif type === String # we need to convert SubString to String
         return :(String($value))
     elseif Configurations.is_option(type)
-        return quote
-            $Configurations.from_toml($type, $value)
-        end
+        return :($TOML.parsefile($value))
     else
         @gensym ret
         return quote


Test patch:
diff --git a/test/codegen/julia/config.jl b/test/codegen/julia/config.jl
index 71457f6..2421413 100644
--- a/test/codegen/julia/config.jl
+++ b/test/codegen/julia/config.jl
@@ -30,6 +30,10 @@ end
     to_toml("config.toml", opt)
     TestConfigOption.command_main(["--config", "config.toml"])
     TestConfigOption.command_main(["-c", "config.toml"])
+
+    opt = TestConfigOption.OptionB(TestConfigOption.OptionA(1, 1), 2)
+    to_toml("config.toml", opt)
+    TestConfigOption.command_main(["--config", "config.toml", "--config.c=1"])
 end
 
 end