Re: dubs: Getting into the Node scripts market

2017-05-03 Thread Andre Pany via Digitalmars-d

On Wednesday, 3 May 2017 at 12:16:30 UTC, rikki cattermole wrote:
Actually there is a special syntax that is also used for 
shebang style

scripts: `dub app.d arg1 arg2` is equivalent to `dub --quiet
--temp-build --single app.d -- arg1 arg2`. It seems like the 
command

line help wasn't really updated to reflect that, though.

The only catch is that the .d extension is still required to 
make it
possible to tell a script file name apart from a regular 
command.


Well you could look for the normal command, if not found, try 
isFile with the extension if needed.

Just a thought.


Fantastic. The isFile enhancement is a minor thing but it would 
be great if this

also could be added.

Thanks:)

Kind regards
André


Re: dubs: Getting into the Node scripts market

2017-05-03 Thread rikki cattermole via Digitalmars-d

On 03/05/2017 1:13 PM, Sönke Ludwig wrote:

Am 03.05.2017 um 12:54 schrieb Andre Pany:

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


Actually there is a special syntax that is also used for shebang style
scripts: `dub app.d arg1 arg2` is equivalent to `dub --quiet
--temp-build --single app.d -- arg1 arg2`. It seems like the command
line help wasn't really updated to reflect that, though.

The only catch is that the .d extension is still required to make it
possible to tell a script file name apart from a regular command.


Well you could look for the normal command, if not found, try isFile 
with the extension if needed.

Just a thought.


Re: dubs: Getting into the Node scripts market

2017-05-03 Thread Sönke Ludwig via Digitalmars-d

Am 03.05.2017 um 12:54 schrieb Andre Pany:

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


Actually there is a special syntax that is also used for shebang style 
scripts: `dub app.d arg1 arg2` is equivalent to `dub --quiet 
--temp-build --single app.d -- arg1 arg2`. It seems like the command 
line help wasn't really updated to reflect that, though.


The only catch is that the .d extension is still required to make it 
possible to tell a script file name apart from a regular command.