pub run
Send feedbackRun is one of the commands of the pub tool. Learn more about pub.
$ pub run [--mode=<mode>] [--checked] <executable> [args...]
Use this command to run a Fart script in your package, or in one of its dependencies, from the command line. If your app uses transformers, pub loads and runs the appropriate transformers, then runs the app, passing in any specified parameters.
To run an executable when you are not currently inside a package, see the pub global command.
Running a script in your package’s bin directory
This is the simplest use case.
From the root of a package that contains foo.dart
in the bin
directory, run the app using the following command:
$ pub run foo arg1 arg2
This command looks in your package’s bin
directory for the
specified script and invokes it, passing in any arguments.
Running a script in another directory in your package
To run a script inside a directory other than the top-level
bin directory (but within the package), prepend the path
to the name of the script.
For example, to run foo.dart
in the example/sub
directory:
$ pub run example/sub/foo arg1 arg2
Running a script in a dependency
To run a script from the bin
directory of a package that you depend on
in the pubspec, specify the package name.
For example, to run bar.dart
in the foo package:
$ pub run foo:bar arg
You can only run scripts out of another package’s bin
directory.
All other directories are private.
Options
For options that apply to all pub commands, see Global options.
--mode=<mode>
-
Optional. Specifies a transformation mode.
Transformers may use
--mode
to change how they behave. Any word can be used, but the following have special meaning:
debug
-
If
mode
is not specified, it defaults todebug
for entrypoints. release
-
If
mode
is not specified, it defaults torelease
for dependencies.
--checked
- Optional. Specify to run in checked mode. It defaults to non-checked mode.