Closed wbehrens-on-gh closed 3 years ago
Files without extension are a design bug but that's a story for different time. I think it's reasonably easy to support it.
I'd like this:
--ext:nims
flag for nimnim e --ext:nims foo # assumes nims extension
nim e --ext:nims foo.nim # assumes nims extension, ie pretends it's a nims file
nim c -r --ext:nim foo.nims # assumes nim extension, ie pretends it's a nim file
nim rst2html --exp:rst foo # assumes rst extension
which is like clang -x cpp foo.c
(etc)
it makes it easy to treat an existing nim file as nimscript as an example use case.
with this, you can write your shebang with a file with no or arbitrary extension as you see fit
this already works, if in foo.nims: chmod u+x foo.nims ./foo
#!/usr/bin/env -S nim e
echo (1,2,defined(nimscript))
with proposed --ext
feature, it'd also work with foo
instead of foo.nims
:
#!/usr/bin/env -S nim e --ext:nims
echo (1,2,defined(nimscript))
and again, you'd also be able to use --ext:nim for native speed (and caching compilation with nim r
)
Sorry to ask, but: This bug looks closed/merged and I've installed a recent nightly build but the --ext:nims option doesn't seem to be there... (invalid command line option)...?
Summary
Remove the requirement for nimscript files to have an extension
Description
Basically every other interpreted language can be use with a #! and no file extension, it would be nice if I want to embed a single nimscript file in a non-nim project and have it appear as any other script.
Additional Information
After discussing this in the nim discord for a while it appears there is no reason why there HAS to be an extension on nimscript files. This could be wrong though and any additional information on the choice to have it be required is welcome.