Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make hooks messages configurable #162

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

zach-sherman
Copy link

...and update them to reflect current usage

why:

  • these messages appeared to be just wrong (referencing aide instead of firstaide or an update command that doesn't appear to exist)
  • and in any case it's nice to have them all customizeable not just the getting_started message. based on the presence of the Messages struct I presume this was always intended

how:

  • add fields to Messages struct, named based on the hook they are associated with
  • set sensible defaults for messages
  • add messages to the hooks scripts
  • splat configured messages into hooks scripts based on how it was done for the getting_started message

docs: updated the readme to document messages configuration

validation: tested new message configurations in a different project, cargo test

...and update them to reflect current usage

why:
- these messages appeared to be just wrong (referencing `aide` instead of firstaide or an `update` command that doesn't appear to exist)
- and in any case it's nice to have them all customizeable not just the getting_started message. based on the presence of the `Messages` struct I presume this was always intended

how:
- add fields to `Messages` struct, named based on the hook they are associated with
- set sensible defaults for messages
- add messages to the hooks scripts
- splat configured messages into hooks scripts based on how it was done for the getting_started message

docs: updated the readme to document messages configuration

validation: tested new message configurations in a different project, `cargo test`
@zach-sherman zach-sherman marked this pull request as draft October 25, 2023 17:40
...and update them to reflect current usage

why:
- these messages appeared to be just wrong (referencing `aide` instead of firstaide or an `update` command that doesn't appear to exist)
- and in any case it's nice to have them all customizeable not just the getting_started message. based on the presence of the `Messages` struct I presume this was always intended

how:
- add fields to `Messages` struct, named based on the hook they are associated with
- set sensible defaults for messages
- add messages to the hooks scripts
- splat configured messages into hooks scripts based on how it was done for the getting_started message

docs: updated the readme to document messages configuration

validation: tested new message configurations in a different project, `cargo test`
@zach-sherman
Copy link
Author

here's a demo of how the default messages show up now:

$ .cache/firstaide-bin/bin/firstaide build
2023-10-25 10:50:42  INFO  Allow direnv in "/Users/z".
2023-10-25 10:50:42  INFO  Create cache dir at ".cache/firstaide-cache".
2023-10-25 10:50:42  INFO  Capture outside environment.
⠙ 2023-10-25 10:50:43  INFO  Capture inside environment (may involve a full build).
⠸ 2023-10-25 10:50:52  INFO  Calculate environment diff.
2023-10-25 10:50:52  INFO  Calculate file checksums.
⠙ 2023-10-25 10:50:52  INFO  Write out cache.
2023-10-25 10:50:52  INFO  Update most recent cache file link.
direnv: loading .envrc                                                                                                                
direnv: OKAY: Nix environment is up to date!
direnv: This is a minimal environment; subprojects may not be built.
direnv: --> Use firstaide --help to find out what to do next.
direnv:         ^^^^^^^^^^^^^^^^
direnv: export +AR +AS +AWS_PROFILE ...
$ rm -rf .cache/firstaide-cache
direnv: loading .envrc                                                                                                                
direnv: ERROR: Nix environment is not yet built!
direnv: --> Use build firstaide and run "firstaide build" to build it.
direnv:         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
$ firstaide build    
2023-10-25 10:51:09  INFO  Allow direnv in "/Users/z/".
2023-10-25 10:51:09  INFO  Create cache dir at "/Users/z/.cache/firstaide-cache".
2023-10-25 10:51:09  INFO  Capture outside environment.
⠙ 2023-10-25 10:51:09  INFO  Capture inside environment (may involve a full build).
⠹ 2023-10-25 10:51:12  INFO  Calculate environment diff.
2023-10-25 10:51:12  INFO  Calculate file checksums.
⠙ 2023-10-25 10:51:12  INFO  Write out cache.
2023-10-25 10:51:12  INFO  Update most recent cache file link.
direnv: loading .envrc                                                                                                                
direnv: OKAY: Nix environment is up to date!
direnv: This is a minimal environment; subprojects may not be built.
direnv: --> Use firstaide --help to find out what to do next.
direnv:         ^^^^^^^^^^^^^^^^
direnv: export +AR +AS +AWS_PROFILE ...
# edit flake.nix and:
$  direnv reload                   
direnv: loading .envrc                                                                                                                
direnv: WARNING: Nix environment is out of date! 
direnv: --> Use firstaide build to rebuild it.
direnv:         ^^^^^^^^^^^^^^^
direnv: WARNING: Loading STALE environment ;-(

...and update them to reflect current usage

why:
- these messages appeared to be just wrong (referencing `aide` instead of firstaide or an `update` command that doesn't appear to exist)
- and in any case it's nice to have them all customizeable not just the getting_started message. based on the presence of the `Messages` struct I presume this was always intended

how:
- add fields to `Messages` struct, named based on the hook they are associated with
- set sensible defaults for messages
- use serde default attributes to allow mixing defaults and custom messages without errors
- add messages to the hooks scripts
- splat configured messages into hooks scripts based on how it was done for the getting_started message

docs: updated the readme to document messages configuration

validation: tested new message configurations in a different project, `cargo test`
@zach-sherman zach-sherman marked this pull request as ready for review October 25, 2023 18:46
@zach-sherman
Copy link
Author

aaand now it allows you to mix default + custom messages. let me know if there's anything else you'd like to see!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant