diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..47ff004 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,3 @@ +[*.sh] +indent_style = space +indent_size = 4 diff --git a/dev.sh b/dev.sh index dcd4408..24cb812 100755 --- a/dev.sh +++ b/dev.sh @@ -2,12 +2,12 @@ # Helper functions not exposed to the user { # Load example data -_init () { +_init() { python ./src/manage.py loaddata src/network_inventory.yaml } # Setup the database -_setup () { +_setup() { overmind start -l db -D if [ -f .direnv/first_run ]; then sleep 2 @@ -41,15 +41,15 @@ _setup () { sleep 2 } -_open_url () { +_open_url() { if [[ ! -z "${DEFAULT_BROWSER}" ]]; then $DEFAULT_BROWSER $url - elif type explorer.exe &> /dev/null; then + elif type explorer.exe &>/dev/null; then explorer.exe $url fi } -_create_url () { +_create_url() { if [ -f /etc/wsl.conf ]; then echo "http://localhost:$WEBPORT" else @@ -62,7 +62,7 @@ _create_url () { declare -A tasks declare -A descriptions -run () { +run() { _setup find . -name __pycache__ -o -name "*.pyc" -delete url=$(_create_url) @@ -76,25 +76,25 @@ tasks["run"]=run descriptions["start"]="Alias for run." tasks["start"]=run -stop () { +stop() { overmind quit } descriptions["stop"]="Stop the webserver and DB." tasks["stop"]=stop -venv () { +venv() { nix build .#venv -o .venv } descriptions["venv"]="Build a pseudo venv that editors like VS Code can use." tasks["venv"]=venv -build-container (){ - nix build && docker load < result && docker run --rm -ti network-inventory:latest +build-container() { + nix build && docker load \n\n" - for task in "${!tasks[@]}" - do + for task in "${!tasks[@]}"; do echo "$task - ${descriptions[$task]}" done else # Check if task is available - if [[ -v "tasks[$1]" ]] ; then + if [[ -v "tasks[$1]" ]]; then ${tasks["$1"]} else echo "Task not found."