dcli
  • Introduction
  • What does DCli do?
  • Install DCli
    • Installing on Windows
  • Writing your first CLI app
  • Add DCli to your project
  • pub.dev
  • github
  • Dart basics
    • Dart lambda functions
    • Function Arguments
    • Futures
    • stdin/stdout/stderr a primer
  • Tour
    • Overview
    • Using DCli functions
    • User input
      • Ask Validators
    • Displaying information
    • Managing Files And Directories
    • Environment variables
    • Calling apps
    • Redirecting output
    • Command Line Arguments
    • Paths
    • Glob Expansion
    • Piping
    • Locking
    • Fetch
    • The evils of CD
    • Assets/Resources
    • Cross Platform
      • Posix
      • Windows
      • Docker
        • Detecting Docker
        • Add DCli to a Docker Container
        • Example DCli app in Docker
  • Elevated Privileges
    • Sudo
  • Performance
  • Dependency Management
    • Dependency Management
    • Pubspec Managment
  • DCli Tools
    • DCli tools
    • Use a shebang #!
    • DCli Compile
    • DCli Clean
    • DCli Create
    • DCli Doctor
    • DCli Install
    • DCli Run
    • DCli Warmup
    • DCli Pack
    • Upgrade DCli
  • Internal Workings
    • Internal Workings
    • waitForEx
  • Contributing
    • Creating a release
    • Running Unit tests
    • Implemention support for a shell
    • Templates
  • References
  • Examples
    • Projects
    • Code
      • hello world.
      • dcompress
      • dpath
      • dmysql
      • dshell
      • dwhich
      • dipaddr
      • gnome launcher
  • Articles
    • build CLI apps in dart - part 1
    • build CLI apps in dart - part 2
    • Dealing with permissions
    • 3rd Party console packages
  • Dart on Linux - the perfect CLI tooling
  • Improving your build environment
    • Existing tooling
    • Building with Dart
    • A home for your build tools
  • Olivier Revial - CLI apps made easy
  • Video: package of the week
Powered by GitBook
On this page
  • Compile a package
  • Flags:
  • --noprepare | -nc :
  • --install | -i :
  • --overwrite | -o :
  • --package | -p

Was this helpful?

  1. DCli Tools

DCli Compile

The compile command will compile your DCli script(s) into a native executable and optionally install it into your PATH.

The resulting native application can be copied to any binary compatible OS and run without requiring Dart or DCli to be installed.

Dart compiled applications are also super fast.

Usage: dcli compile [-nc, -i, -o] [<script path.dart>, <script path.dart>,...]

Example:

dcli compile hello_world.dart

./hello_world
dcli compile hello_world.dart

./hello_world
dcli compile hello_world.dart

hello_world.exe

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

hello_world

Compile a package

DCli can also compile a globally activated package.

dart pub global activate critical_test
dcli compile --package critical_test
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.

Flags:

--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.

PreviousUse a shebang #!NextDCli Clean

Last updated 2 years ago

Was this helpful?