Search…
DCli Create
The dcli create command makes it easier to create new scripts.
The dcli create command create a sample DCli script using the given script file name and initialise your project by running dcli prepare.
dcli create performs the following actions:
  • creates <script.dart>
  • creates pubspec.yaml
  • creates analysis_options.yaml
  • marks your script as executable
  • adds a shebang #! to the start of your script.
  • runs dcli prepare in the background.
dcli create won't create the pubspec.yaml nor analysis_options.yaml if you create your new script in an existing dart project.
Usage: dcli create <script.dart>
Example:
1
dcli create my_script.dart
2
Creating project.
3
DCli prepare started in the background.
4
5
To run your script:
6
./my_script.dart
Copied!
vscode users: edit the project by typing 'code .' on the command line.
As the sample script has a Shebang #! added you can execute it directly:
1
./my_script.dart
Copied!
If you run you script immediately after creating it, the background 'warmup' may still be running.
In which case you may see the message:
1
./test.dart
2
Waiting for warmup to complete...
3
Hello World
Copied!
The warmup process is a once off process and only needs to be run again if you change your dependencies.
The first time you run a given DCli script (created with dcli create), DCli needs to resolve any dependencies by running a Dart pub get command and doing some other housekeeping.
If you run the same script a second time DCli has already resolved the dependencies and so it can run the script immediately.

Flags

The dcli create command accepts the following flags:
-- foreground :
If the foreground flag is passed the dcli warmup process will be ran in the foreground rather than the use background execution.
Now lets create and run our first DCli script.
Last modified 1mo ago
Copy link
Contents
Flags