set quiet app_version := `sed -n 's/^version: *\(.*\)/\1/p' ./glyph.cabal` sources := justfile_directory() / "app" + " " + justfile_directory() / "lib" + " " + justfile_directory() / "dhall" + " " + justfile_directory() / "test" # Print available commands help: just --justfile {{ justfile() }} --list # Print the version from the cabal file version: echo {{ app_version }} # Format all the things format: fourmolu -i {{ sources }} stylish-haskell -ir {{ sources }} cabal-fmt -i {{ justfile_directory() }}/glyph.cabal nixfmt {{ justfile_directory() }}/shell.nix prettier --write --log-level warn --no-error-on-unmatched-pattern --ignore-path {{ justfile_directory() }}/.gitignore "{{ justfile_directory() }}/**/*.md" # Lint the Haskell sources lint: hlint {{ sources }} # Build the executable and the test suite build: cabal build all --enable-tests # Run the test suite test: gen cabal test # Run the editor run *ARGS: gen cabal run glyph -- {{ ARGS }} # Run the editor gen *ARGS: cabal run gen-dhall -- {{ ARGS }} # Rebuild, retest, or rerun whenever a source file changes watch TARGET="test": #!/usr/bin/env bash set -euo pipefail case "{{ TARGET }}" in build) command=(just build) ;; test) command=(just test) ;; run) command=(just run) ;; lint) command=(just lint) ;; *) echo "unknown watch target '{{ TARGET }}' -- expected build, test, run, or lint" >&2 exit 1 ;; esac watchexec --exts hs,cabal --restart -- "${command[@]}" # Build Haddock docs for glyph and its dependencies, then index them into a local Hoogle database hoogle-gen: #!/usr/bin/env bash set -euo pipefail if [[ -z "${GLYPH_GHC_DOCS:-}" ]]; then echo "GLYPH_GHC_DOCS is unset -- run this from inside the project's nix-shell" >&2 exit 1 fi cd "{{ justfile_directory() }}" cabal haddock all --project-file=cabal.project.hoogle --builddir=dist-newstyle/hoogle locals=(--local="$GLYPH_GHC_DOCS" --local=dist-newstyle/hoogle) shopt -s nullglob for dir in "$(cabal path --store-dir)"/ghc-"$(ghc --numeric-version)"*/*/share/doc/html/; do locals+=(--local="$dir") done mkdir -p .hoogle hoogle generate --database=.hoogle/glyph.hoo "${locals[@]}" # Query the local Hoogle database: `just hoogle search QUERY...` or `just hoogle server [PORT]` [positional-arguments] hoogle MODE="server" *ARGS: #!/usr/bin/env bash set -euo pipefail database="{{ justfile_directory() }}/.hoogle/glyph.hoo" if [[ ! -f "$database" ]]; then echo "no Hoogle database at $database -- run 'just hoogle-gen' first" >&2 exit 1 fi shift case "{{ MODE }}" in search) if [[ $# -eq 0 ]]; then echo "usage: just hoogle search QUERY..." >&2 exit 1 fi hoogle search --database="$database" "$@" ;; server) hoogle server --database="$database" --local --port="${1:-8080}" ;; *) echo "unknown hoogle mode '{{ MODE }}' -- expected search or server" >&2 exit 1 ;; esac # Everything CI would check check: build test lint echo "all checks passed"