From b373aca0709062f142f55da0405c37381222e3b5 Mon Sep 17 00:00:00 2001 From: xenia Date: Wed, 9 Aug 2023 19:55:23 +0200 Subject: [PATCH] =?UTF-8?q?l=C3=A4tt=20till=20last?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/devShellHook.sh | 44 +++++++++++++++++++++++++++++++++++-------- flake.nix | 2 +- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/build/devShellHook.sh b/build/devShellHook.sh index a926772..63161ce 100644 --- a/build/devShellHook.sh +++ b/build/devShellHook.sh @@ -1,33 +1,61 @@ set -e log() { - printf '\e[1m\e[38;5;87m==>\e[0m\e[1m %s.\e[0m\n' "$*" + printf "\e[1m\e[38;5;87m==>\e[0m\e[1m %s%s\e[0m\n" "$1" "${2:-.}" } exitHook() { - log "Stopping postgres" + log "Stoppar brevekorren" pg_ctl stop --pgdata=./matabas-db } -log "Checking for existing postgres directory" +log "Letar efter existerande brevekorresmapp" [ -d ./matabas-db ] || { - log "Non-existent, creating postgres directory (./matabas-db)" + log "Finns ej, skapar brevekorresmapp (./matabas-db)" pg_ctl initdb --pgdata=./matabas-db } [ -f matabas-db/matabas.log ] && { - log "Moving logs from last session into log archive (./matabas-db/matabas.log.old)" + log "Flyttar journalen från senaste sittningen till journalarkivet (./matabas-db/matabas.log.old)" cat matabas-db/matabas.log >> matabas-db/matabas.log.old rm -f matabas-db/matabas.log } -log "Starting postgres" +log "Startar brevekorren" pg_ctl start --pgdata=./matabas-db --log=./matabas-db/matabas.log --options="-p 2137 -k /tmp" trap exitHook EXIT -log "Creating database" +log "Skapar matabas" createdb -p 2137 matabas 2>>./matabas-db/matabas.log || log "Database already exists, not overwriting" -log "Environment ready!" +log "Försvensknar miljön" +_cargo() { + cuh="$1" + shift + case "$cuh" in + kör|spring) + cargo run "$@" + ;; + ny) + cargo new "$@" + ;; + pröva) + cargo test "$@" + ;; + bygg) + cargo build "$@" + ;; + enna) + cargo init "$@" + ;; + *) + echo "vafan gö du" + ;; + esac +} +alias 'last=_cargo' +alias cargo=exit + +log "Redo" "!" set +e diff --git a/flake.nix b/flake.nix index 718804f..a4c9aec 100644 --- a/flake.nix +++ b/flake.nix @@ -14,7 +14,7 @@ default = pkgs.hello; }; devShells.default = pkgs.mkShell { - packages = [ packages.default pkgs.postgresql_15_jit ]; + packages = [ packages.default pkgs.postgresql_15_jit pkgs.cargo ]; shellHook = builtins.readFile ./build/devShellHook.sh ; }; }