You may specify one or more scripts and DCli will compile each of them.
If you don't specify any scripts then DCli will compile all scripts in the current directory.
If you use the --install option the compiled exe will be added to your path.
DCli copies the executable into ~/.dcli/bin which is added to your path when you run dcli install.
dcli compile --install hello_world.dart
Compile a package
DCli can also compile a globally activated package.
dart pub global activate critical_test
dcli compile --package critical_test
The compiled package will be automatically copied into the ~/.dcli/bin directory which is on your PATH.
Compiling a globally activated package has a number of uses:
faster startup time
you are able to copy the resulting executable to any binary compatible machine and run it without installing Dart
If you switch Dart versions then the executable will still run even if the package isn't compatible with the installed Dart version. This can be useful if you need to run an old version of dart but want access to the latest version of a Dart CLI package.
When compiling a package DCli will create an executable for each of the scripts listed in the packages pubspec.yaml executables section.
Ensure that ~/.dcli/bin is on your PATH and is before ~/.pub-cache or the globally activate version will run rather than you compiled version.
--noprepare | -nc :
stop DCli from running prepare before doing a compile. Use this option if you know that you script's dependencies haven't changed since the last compile resulting in a faster compile.
--install | -i :
install the compiled script into the ~/.dcli/bin directory which is on your path. -
--overwrite | -o :
if the target script has already been compiled and installed, you must specify the -o flag to allow DCli to overwrite it.
--package | -p
compiles a globally activated package and installs it into the !/.dcli/bin directory.