The only way to do that right now is to create a root jsonnet file which imports the others.
We have previously considered adding a feature to allow you to import a directory, which would yield an object whose keys were the filenames. However this is a bit of a can of worms:
- Just *.jsonnet files or every file (it's lazy so if you don't actually inspect the file it won't matter)
- Should it allow importing a wildcard?
- Add the same feature for importstr?
- What about dirs containing a mixture of text and jsonnet files?
- Should it be recursive?
What you're suggesting is much less of a can of worms because it's an explicit list of files on the commandline, and it's safe to assume they're all Jsonnet files (otherwise what can we actually do with them). However it wouldn't be possible to do the same thing from within the language itself, which might be a bit weird.
Without any of this, there is still a simple hack you can do: (If you want to output it as an array instead, you can tweak it.)
dcunnin@casterly:~/tmp$ cat a.jsonnet
"a"
dcunnin@casterly:~/tmp$ cat b.jsonnet
"b"
dcunnin@casterly:~/tmp$ jsonnet -e -- "$(ls *.jsonnet | sed -e '1i{' -e 's/.*/ "&": import "&",/' -e '$a}')"
{
"a.jsonnet": "a",
"b.jsonnet": "b"
}