dubs: Getting into the Node scripts market

Andre Pany via Digitalmars-d digitalmars-d at puremagic.com
Wed May 3 03:54:46 PDT 2017


Hi,

it would be great if we can position D as replacement of Node 
scripts. With the --single argument of Dub we have almost 
everything we need in this scenario.

But one thing is very odd. If you want to execute the app.d 
source file with dub you have to write: dub --single app.d

- You have to remember the argument --single
- You have to add the .d extension
- You do not like to have the binary created, therefore you have 
to add --temp-build
- You do not like to have too much output, therefore you have to 
add --quiet
- If you have application arguments you have to know to add -- at 
the end followed by the application arguments.

With these limitations I cannot convince a Node developer to 
switch to D.
I created a very small batch file dubs.bat which would have a 
huge impact in this scenario.
You can execute the D source file with: dubs app
Application arguments are just appended: dubs app --PORT 8080

-- dubs.bat
@echo off
set _filename=%~n1
set _extension=%~x1
for /f "tokens=1,* delims= " %%a in ("%*") do set 
_args_without_filename=%%b

IF "% _extension%" == ".d" (
	set _sourceFile=%_filename%
) else (
	set _sourceFile=%_filename%.d
)

dub run --temp-build --quiet --single %_sourceFile% -- 
%_args_without_filename%
-- dubs.bat

Do you think it makes sense to add this batch file and a linux 
equivalent shell script to the D compilers?

Kind regards
André Pany


More information about the Digitalmars-d mailing list