dpad
is your local dart scripting environment. This is a simple guide to start using dart scripts across your machine.
dart
installed (I recommend usingpuro
to 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 .
: makesdpad
an 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.dart
for now) - Add the
dpad
function to you.zshrc
dpad() { 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
dpad
shell 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
~/.zshrc
in case you might need it in dart or other scripts: