Use a shebang #!
A Shebang is a special entry on the first line of your script that tells the OS which command interpreter to use to execute your script.
By adding a Shebang to the start of you Dart script you can directly run a script from the cli.
Without a Shebang:
With a Shebang:
It's a small difference but rather useful particularly if you are calling one script from another.
You do NOT need the DCli tools if you just want to use the DCli API but they are required if you want to use the Shebang feature.
If you want to use the DCli tools you must first activate them.
So let's look at how hello.dart looks with a shebang added.
On Linux and OSX you must mark the file as executable for the Shebang to work.
Mark the file as executable:
Now run the script from the cli:
You're now officially in the land of DCli magic.
Faster you say?
Last updated
Was this helpful?