dpad is your local dart scripting environment. This is a simple guide to start using dart scripts across your machine.
dartinstalled (I recommend usingpuroto manage dart/flutter versions)- bash/zsh-like environment (this is likely possible in other terminals but idk how to set that up and am too lazy to tell you)
These steps should only be run once for the setup.
- Create
dpad:dart create dpad cd dpad- Try
dart run(optional):Building package executable... Built dpad:dpad. Hello world: 42! dart pub global activate -s path .: makesdpadan available executable on your systemResolving dependencies... Got dependencies! Activated dpad 1.0.0 at path "/path/to/dpad".- Try
dart pub global run dpad(optional):
Same entry point as theBuilding package executable... Built dpad:dpad. Hello world: 42!dart run(which targetsdpad/bin/dpad.dartfor now) - Add the
dpadfunction to you.zshrcdpad() { dart pub global run dpad:$1 ${@:2} } - Restart your terminal
- Write new scripts/entry points under
dpad/bin/*.dart:dpad/bin/my_new_script.dart - Execute them with the
dpadshell function:dpad my_new_script - Arguments are forwarded to the
void main(List<String> args) { } - Write shared code under
dpad/lib - Manage your own dependencies and code analysis
I find it helpful to add an environment variable in
~/.zshrcin case you might need it in dart or other scripts: