Skip to content

Commit

Permalink
chore: add cmd to pretty print scripts and descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Zambelli committed Sep 23, 2024
1 parent 89baf53 commit 7b9cad9
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,34 @@ in

# convenient shortcuts
scripts.up.exec = "devenv up -d";
scripts.up.description = "Start processes defined in devenv.nix in the background.";
scripts.up.description = "Start processes in the background.";

scripts.down.exec = "devenv processes down";
scripts.down.description = "Stop processes defined in devenv.nix in the background.";
scripts.down.description = "Stop processes.";

scripts.tests.exec = "pytest && rm -rf ./tmp";
scripts.tests.description = "Run pytest and cleanup.";

scripts.show.exec = ''
GREEN="\033[0;32m";
YELLOW="\033[33m";
NC="\033[0m";
echo
echo -e "✨ Helper scripts you can run to make your development richer:"
echo
${pkgs.gnused}/bin/sed -e 's| |••|g' -e 's|=| |' <<EOF | ${pkgs.util-linuxMinimal}/bin/column -t | ${pkgs.gnused}/bin/sed -e "s|^\([^ ]*\)|$(printf "$GREEN")\1$(printf "$NC"): |" -e "s|^|$(printf "$YELLOW*$NC") |" -e 's|••| |g'
${lib.generators.toKeyValue { } (
lib.mapAttrs (name: value: value.description) (
lib.filterAttrs (_: value: value.description != "") config.scripts
)
)}
EOF
echo
'';
scripts.show.description = "Print this message and exit.";

# https://devenv.sh/packages/
packages = with pkgs; [
nixfmt-rfc-style
Expand Down Expand Up @@ -92,6 +112,7 @@ in

enterShell = ''
hello
show
'';

# https://devenv.sh/pre-commit-hooks/
Expand Down

0 comments on commit 7b9cad9

Please sign in to comment.