pietroppeter / nimib

nimib 🐳 - nim 👑 driven ⛵ publishing ✍
https://pietroppeter.github.io/nimib/
MIT License
176 stars 10 forks source link

better error message for `nbInitPython`, `nbPython` and the like (`nbKarax`, ...) #95

Open pietroppeter opened 2 years ago

pietroppeter commented 2 years ago

some templates (e.g. nbInitPython, nbPython) require additional dependencies in order to be used (e.g. nimpy), dependencies that are not need by nimib. Currently if a user of nimib tries to call nbPython without having nimpy module available the error will be somthing like nbPython not found (since the template in nimib.nim is wrapped in a when moduleAvailable(nipmy)).

To improve the error message we could (instead of wrapping in the when) add as first line of any template that requires an additional dependency, a new onlyWhenModuleAvailable(requiredModule) template that gives the correct error message: "to use myTemplate you need to have module requiredModule available, check nimib.nimble on github to see constraints on version number".

And probably instead of a onlyWhenModuleAvailable template it should be a pragma to get name of template (or we just pass it); do template allows pragmas? a requiresModule seems general purpose enough... (but likely applies only to templates...)

pietroppeter commented 1 year ago

another interesting option: https://github.com/openpeep/pkginfo

HugoGranstrom commented 1 year ago

I don't really understand how it works, tried looking at the source but didn't become much wiser 🤔