From c51c7a757cd9e06d3ccfde3c1b630d62f6bc0093 Mon Sep 17 00:00:00 2001 From: coolneng Date: Tue, 19 Oct 2021 10:18:31 +0200 Subject: [PATCH] Refactor project-init script --- scripts/.local/share/scripts/project-init | 41 +++++++++++++---------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/scripts/.local/share/scripts/project-init b/scripts/.local/share/scripts/project-init index 208f546..32e364e 100755 --- a/scripts/.local/share/scripts/project-init +++ b/scripts/.local/share/scripts/project-init @@ -9,6 +9,22 @@ usage() { exit 1 } +copy_nix_files() { + cp ~/Documents/IT/shell.nix . + cp ~/Documents/IT/flake-template.nix flake.nix +} + +git_initialization() { + git init + git add ./* + git commit -m "Initial commit" +} + +direnv_integration() { + echo "use flake" >.envrc + direnv allow +} + if [ $# != 1 ]; then usage fi @@ -16,35 +32,26 @@ fi type=$1 if [ "$type" = "git" ]; then - git init - cp ~/Documents/IT/shell.nix . - cp ~/Documents/IT/flake-template.nix flake.nix mkdir src data - git add ./* - git commit -m "Initial commit" - echo "use flake" >.envrc - direnv allow + copy_nix_files + git_initialization + direnv_integration elif [ "$type" = "remote-git" ]; then - git init touch README.org cp ~/Documents/IT/gpl-3.0.md LICENSE.md - cp ~/Documents/IT/shell.nix . - cp ~/Documents/IT/flake-template.nix flake.nix + copy_nix_files mkdir src tests data - git add ./* - git commit -m "Initial commit" - echo "use flake" >.envrc - direnv allow + git_initialization + direnv_integration elif [ "$type" = "doc" ]; then mkdir docs docs/assets touch docs/Summary.org touch .project elif [ "$type" = "src" ]; then - cp ~/Documents/IT/shell.nix . + copy_nix_files mkdir src data touch .project - echo "use nix" >.envrc - direnv allow + direnv_integration else usage fi