Created
October 31, 2020 09:49
-
-
Save dumazy/b5f64d4c544489569b65be7a30990983 to your computer and use it in GitHub Desktop.
Flutter sandbox script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Absolute path of the Flutter sandbox project | |
sandbox_path="/Users/fre.dumazy/Developer/Playground/flutter_sandbox" | |
# Name of Android emulator to open. | |
# Check with `emulator -list-avds` | |
avd_name="Pixel_4_API_30" | |
main() { | |
processOptions "$@" | |
resetSandbox | |
openVsCode | |
} | |
openVsCode () { | |
# Open the project in VS Code at the main.dart file | |
code "$sandbox_path" "$sandbox_path/lib/main.dart" | |
} | |
usage () { | |
echo "Usage: $0 [-i] [-a]" | |
} | |
processOptions () { | |
while getopts ":ia" flag; do | |
case "${flag}" in | |
i) | |
startSimulator | |
;; | |
a) | |
startEmulator | |
;; | |
*) | |
usage | |
;; | |
esac | |
done | |
} | |
startSimulator () { | |
open -a Simulator | |
} | |
startEmulator () { | |
# Start emulator in a background process and ignore logs in terminal | |
emulator -avd "$avd_name" > /dev/null 2>&1 & | |
} | |
resetSandbox () { | |
(cd "$sandbox_path" && git reset --hard > /dev/null 2>&1) | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment