156 Commits

Author SHA1 Message Date
Etan Kissling
cb858a27f4
Fix cli invocation from nimscript (#109)
* Fix `cli` invocation from nimscript

When calling `cli` macro from nimscript, there are compilation issues:

- `nim-faststreams` is not available, therefore, `nim-serialization`
  does not work, due to `equalMem` being gated behind `notJSnotNims`.
  Dropping support for config files in nimscript contexts fixes that.

- `std/strformat` raises `ValueError` for invalid format strings, but
  does so at runtime rather than checking types at compiletime. As it
  is only used for simple string concatenation in error cases, changing
  to simple concatenation avoids verbose error handling.

- `getAppFilename()` is unavailable in `nimscript`. This was already
  fixed by replacing it with `appInvocation()` but two instances of
  direct `getAppFilename()` calls remained in default arguments.
  This is fixed by changing those default arguments as well.

- The `!= nil` check on the `proc` in `loadImpl` does not work when
  called from nimscript. This is fixed by changing to `isNil`.

- Passing `addr result` around to internal templates correctly creates
  the config, but the object ultimately being returned is not the same.
  Passing `var result` directly through the templates ensures that the
  correct `result` gets modified and is clearer than implicit capture.

Applying these fixes fixes running `.nims` files with `cli` macro.

* Add debugging output on failure

* Update confutils.nimble

* Update confutils.nim
2024-10-30 10:49:34 +00:00
Etan Kissling
9bf293e5d2
Replace apt-fast with apt-get (#108)
`apt-fast` was removed from GitHub with Ubuntu 24.04:

- https://github.com/actions/runner-images/issues/10003

For compatibility, switch back to `apt-get`.
2024-10-15 14:34:20 +00:00
Jacek Sieka
2717b21b87
avoid threadvar (#107) 2024-10-01 17:12:56 +02:00
Miran
d5274f8e97
update ci.yml to test Nim 2.2; also test gcc-14 (#105) 2024-09-24 05:00:15 +00:00
Miran
cb640db2cd
update ci.yml and be more explicit in .nimble (#104) 2024-07-01 18:06:47 +02:00
Etan Kissling
0adf3b7db7
add missing {.raises.} to addConfigFileContent (#103)
`addConfigFileContent` can raise `ConfigurationError`. Declare so.
2024-02-20 21:14:04 +00:00
andri lim
57ff0b8555
Add push raises (#101)
* Add push raises

* Fix gcsafe violation

* remove debug code
2024-02-12 12:39:19 +07:00
jangko
7340359702
Add copyright to source code 2024-02-12 10:26:05 +07:00
jangko
4797be7ea8
Upgrade github actions to v4 2024-01-27 17:02:52 +07:00
ringabout
0fe16fac47
Add ORC testing for the devel branch (#98) 2024-01-26 13:41:00 +07:00
Vit∀ly Vlasov
fa6e9b09e2
Dynlib fix for status-go integration (#97)
* Dynlib fix as suggested in https://github.com/status-im/nim-confutils/issues/31

* Update confutils.nim

* Declare empty commandLineParams if the standard one is not declared.

---------

Co-authored-by: Jacek Sieka <arnetheduck@gmail.com>
2024-01-25 13:18:50 +01:00
tersec
7217854b60
rm deprecated ValidIpAddress support (#96) 2024-01-25 12:05:18 +01:00
tersec
7568f1b7c3
support IpAddress in contexts ValidIpAddress is supported (#95) 2023-10-27 09:49:03 +00:00
tersec
07b598ff28
add IpAddress equivalents for ValidIpAddress support (#94) 2023-10-26 02:30:34 +00:00
Etan Kissling
674c9e4c8e
explicitly initialize result (#89)
In Nim 2.0, `'result' requires explicit initialization`.

Fix `makeDefaultValue` to do so.
2023-08-20 12:40:32 +02:00
Etan Kissling
d784b823be
add {.raises.} annotation to writeValue (#88)
Tag `writeValue` override with `{.raises: [IOError].}`.
2023-08-19 18:31:42 +02:00
Etan Kissling
3c7c1cfc76
fail on error while processing secondarySources (#82)
The way how `secondarySources` are used in `status-im/nimbus-eth2`,
they call `addConfigFile` again which may raise `ConfigurationError`.
When that happened, loading the primary config file didn't result in
`fail`, which differs in error handling from errors within itself
as opposed to within `secondarySources`. To keep callers concise,
apply same error handling behaviour regardless of whether the error
occurred during primary or secondary sources processing.
2023-08-17 13:32:47 +02:00
Etan Kissling
dbe8d61f7f
require secondarySources to be gcsafe (#86)
Avoid Nim 2.0 warning in callers of `confutils.load`.

```
Warning: 'loadImpl' is not GC-safe as it performs an indirect call via 'secondarySources' [GcUnsafe2]
```
2023-07-31 14:56:44 +02:00
Etan Kissling
c67257660b
return empty completion lines on unsupported COMP_POINT (#76)
When `COMP_POINT` is invalid or out of range, return an empty list of
completions instead of raising `ValueError`. This matches behaviour for
`comp_point < 0 or comp_point > len(comp_line)` cases.
2023-07-07 14:03:23 +03:00
Etan Kissling
d0d6fb45b2
catch exceptions in splitCompletionLine (#77)
We currently return `@[]` in `splitCompletionLine` when there is
unexpected or unsupported input via environment variables, but let
exceptions during parsing propagate to the caller. Catching those
exceptions allows the caller to use same behaviour regardless of
the nature of unexpected input (either through env, or parsing).
Currently, callers don't seem to be aware of the exceptions, so
going with the behaviour used for environment errors of returning `@[]`.
2023-06-13 10:36:33 +02:00
Etan Kissling
7f17285d4e
restrict parseCmdArgAux to ValueError (#83)
Value parsers are currently allowed to raise `CatchableError`, but in
practice only `ValueError` is raised. Restrict to `ValueError`, and also
properly convert them to `fail` / `ConfigurationError` if applicable.
2023-06-12 16:25:39 +02:00
Etan Kissling
b30f22da26
suppress unreachable string format errors (#81)
* suppress unreachable string format errors

We use `%` and `&` to format some strings, which may raise `ValueError`
if the format string is weird. As we are using them in ways that should
always succeed, catch those `ValueError` and convert to asserts.

* add `{.raises: [].}`
2023-06-09 19:16:55 +00:00
Etan Kissling
6c3566850d
catch exceptions in appInvocation (#78)
The `appInvocation` template in `confutils` is used while showing help,
e.g., before quitting. To ensure that `quit` actually happens, it can't
raise exceptions. Fix that by falling back to `""` on `OSError`.
2023-06-08 13:30:46 +00:00
Etan Kissling
50f744d821
handle terminalWidth exception (#80)
`terminalWidth()` may fail with a `ValueError` on out of range widths
from environment variables. Provide a suitable fallback.
2023-06-08 13:28:44 +00:00
Etan Kissling
4dbd23af3b
ignore exceptions while writing to stdout/stderr (#79)
`writeLine` can fail with `IOError`, and `styledWrite` when using colors
also with `ValueError`. To ensure that the control flow is unaffected,
simply ignore those errors while writing human-readable output to fds.
2023-06-08 13:26:06 +00:00
Etan Kissling
8522393cec
annotate parseCmdArg with {.raises.} (#84)
For the `parseCmdArg` that may fail with `ValueError`, add annotations.
2023-06-08 13:25:05 +00:00
tersec
10e53c3a67
use --mm: instead of --gc: and remove stddefects import (#85)
* use --mm: instead of --gc: and remove stddefects import

* remove incorrect trailing ":" from line
2023-06-08 13:12:32 +00:00
tersec
1f3acaf6e9
remove support for Nim v1.2 and v1.4 (#75) 2023-05-31 15:37:01 +00:00
Adam Uhlíř
2028b41602
feat: integrate env. variable support natively (#70) 2023-04-19 12:54:48 +03:00
jangko
6c6ff76cb3
remove travis badge from readme.md 2023-04-14 22:06:01 +07:00
tersec
273aa6cc3f
test both refc and ORC in post-1.6 Nim versions (#73) 2023-04-13 23:35:19 +00:00
Vaclav Pavlin
51a881a9c7
Remove nimble.lock to unblock building and running tests (#72) 2023-04-11 11:24:34 +02:00
tersec
296f21483f
run CI on Nim 2.0 2023-04-07 11:02:59 +00:00
tersec
c8063eb814
use correct check for Nim versions with BareExcept warning 2023-03-20 19:06:25 +00:00
Zahary Karadjov
c4c11c52ce
Add a simple helper for writing tests involving config file contents 2023-03-14 17:24:38 +02:00
jangko
38dfeaaabd
reduce compiler warnings 2023-02-15 15:26:53 +07:00
jangko
a1f3b22bbe
fix ci for nim 1.6 and devel
- rm -f nimble.lock to allow nim 1.2,1.4,1.6, and devel run test with nimble
- upgrade ubuntu runner to 20.04
- upgrade github actions to v3
2023-02-12 13:05:41 +07:00
Kim De Mey
f6acc5e3da
Add custom Enum parser proc to keep Nim 1.2 behaviour for configs (#63) 2023-01-26 10:42:14 +01:00
Luke
56f4db90f7
Update confutils.nimble (#57)
Co-authored-by: Jacek Sieka <jacek@status.im>
2022-11-23 19:30:59 +01:00
Jacek Sieka
269c17401d
update CI, normalise nimble (#61) 2022-11-23 17:30:29 +01:00
jangko
a26bfab7e5
fix config file test due to toml-serialization changes 2022-09-23 09:45:15 +07:00
Miran
b098d9ea85
move -d:nimRawSetjmp to config.nims (#54)
* move `-d:nimRawSetjmp` to config.nims

Refs https://github.com/status-im/nimbus-build-system/issues/44

* use .cfg not .nims
2022-09-03 08:35:01 +02:00
Ivan Yonchovski
40c6f0b378
Add setup files (#55) 2022-07-12 23:33:45 +03:00
Zahary Karadjov
5d0d864510
FieldTag no longer requires specifying the FieldType 2022-06-18 13:30:42 +03:00
tersec
fc03a0c4e1
rm TaintedString for string; some proc -> func (#53)
* rm TaintedString for string; some proc -> func

* procs which interact with macros in certain ways can't be funcs in Nim 1.2
2022-06-03 18:24:59 +00:00
jangko
d06f6187dc
fix #49: field type with qualified ident 2022-05-10 12:18:06 +07:00
jangko
8f8f715f76
fix nnkAccQuoted entry processing in config-file
fixes #47
2022-04-16 18:28:38 +07:00
Dustin Brody
60d71e8029
rm obsolete/unused/unmaintained CI AppVeyor and Travis scripts 2022-04-03 08:09:46 +00:00
tersec
a4f51237fc
add parseCmdArg tests; fix 64-bit int parsing on 32-bit platforms (#44) 2022-03-23 14:30:29 +02:00
Ștefan Talpalaru
9826fddd1c
fix corner case with custom pragma (#42)
The AST changes when you call the same custom pragma more than once.
2022-03-11 14:28:28 +01:00