proj.fish

 1function proj --description 'Personal project helpers (devkit scaffold)'
 2    set -l template git+https://git.kilimanjaro.io/devkit
 3
 4    if test (count $argv) -eq 0
 5        echo "usage: proj init [DIR]" >&2
 6        return 2
 7    end
 8
 9    switch $argv[1]
10        case init
11            # Optional DIR: create it and cd in before scaffolding.
12            if set -q argv[2]
13                mkdir -p $argv[2]; or return 1
14                cd $argv[2]; or return 1
15            end
16            echo "Initializing devkit project in "(pwd)"..." >&2
17            # --refresh forces re-resolving the branch; without it nix reuses the
18            # cached ref for tarball-ttl (default 1h) and misses new template commits.
19            command nix --extra-experimental-features 'nix-command flakes' \
20                flake init --refresh -t $template
21            or return 1
22            echo "Scaffold written. Next: devenv shell" >&2
23        case '*'
24            printf 'proj: unknown subcommand: %s\n' $argv[1] >&2
25            echo "usage: proj init [DIR]" >&2
26            return 2
27    end
28end