On Sun, 02 Nov 2014 17:09:04 -0500, Matt Soucy wrote:

On 10/31/2014 09:59 AM, Colin Grogan wrote:

When using dub to init projects, it can sometimes be annoying to manually look up each project on code.dlang.org to find the newest version for each required dependency, just so you can copy-paste that into the dub.json file.

Would there be much appetite for extending the init command to take in a list of dependency projects, and have it go and look up the DB to find the most recent version string and create the required dub file for you?

So:
dub init myProject openssl logger

would automatically add: (correct at time of writing)

"openssl": ">=1.1.3+1.0.1g"
"logger": ">=0.3.3"

to your dependencies section.

It already supports this somewhat with passing vibe.d to the init command, though I dont know if this goes to the server to find the most recent version number.

Assuming it can fail gracefully, so that I can start a project without having an internet connection, I think it'd be a fantastic feature.

Matt Soucy

Yeah, thats an important aspect of it alright. It should be seamless to what is currently there I think.

I've been tinkering with dub and there's a few ways of doing it.

The way I'm favoring would be to download the package list (Using dub update-local-list or something like that) and save it to a file in ~/.dub.
When you run

dub init dep1 dep2

it checks that file for dep1, dep2 and sticks it into your dub.json.

That would probably be the easiest and most non-intrusive way of doing it.

If dub had to search the server for every init it would probably make it notably slower (network latency be slow and all), plus you run into situations where there's no network connection as you say, complicating logic.

I'm tinkering with it anyway, will post something here soon!