tweag / nix_bazel_codelab

Nix+Bazel Codelab
Apache License 2.0
50 stars 4 forks source link

Add a script to manage solutions #20

Closed rapenne-s closed 2 years ago

rapenne-s commented 2 years ago

I made a new script codelab_compare.sh but the name can be changed, I don't really like it. The solutions have been moved from the generate_build_files.sh to a solutions/ subdirectory.

The script provides commands like diff, display, install and install_all to help you in the exercises to

I think it's the best approach so the solutions files are readable and not embedded in a script, the solutions are lying in the same working directory and not in another branch, and it's still interactive without having to replace your work when looking for help.

> ./codelab_compare.sh help
Usage: ./codelab_compare.sh [compare|display|install|help] path/to/BUILD.bazel

    compare: show the differences between the solution and your version
    display: display the solution (aliased to cat and show)
    install: copy the solution, overwrite file if any

Usage: ./codelab_compare.sh install_all

    install_all: copy all the solutions files, overwriting files if any

Example: ./codelab_compare.sh compare go/cmd/server/BUILD.bazel
fricklerhandwerk commented 2 years ago

I like the idea a lot. A few considerations for me to also love the implementation:

rapenne-s commented 2 years ago

I moved the script to bin/lab however I don't see how to integrate it in nix-shell, do you have some hints?

I added some checks making sure:

I'll take a look at the CI after the script has been refined

rapenne-s commented 2 years ago

Ok, found a way to provide lab in the $PATH when using nix-shell

rapenne-s commented 2 years ago

I moved the reference WORKSPACE into the new solutions/ directory and deleted the script containing it.

rapenne-s commented 2 years ago

lab can now be used from anywhere in the git directory and not only the top level.

rapenne-s commented 2 years ago

I forgot to add a paragraph about lab in the README.md, @fricklerhandwerk could you review it?

rapenne-s commented 2 years ago

Thanks for your time reviewing my work @fricklerhandwerk