Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
amtoine committed Jun 29, 2024
1 parent f900c9b commit e319652
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nu-hooks/nu-hooks/nuenv/hook.nu
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ def get-allowed []: [ nothing -> list<string> ] {
}
}

# setup a hook that will try to load `.env.nu` if it is allowed
#
# # Example
# ```nushell
# use nu-hooks/nuenv/hook.nu [ "nuenv allow", "nuenv disallow" ]
# $env.config.hooks.env_change.PWD = (use nu-hooks/nuenv/hook.nu; hook setup)
# ```
export def setup []: [ nothing -> record<condition: closure, code: string> ] {
{
condition: {|_, after| $after | path join '.env.nu' | path exists }
Expand Down Expand Up @@ -52,6 +59,7 @@ def check-env-file [] {
}
}

# adds `./.env.nu` to the list of allowed "env" files
export def "nuenv allow" [] {
check-env-file

Expand All @@ -68,6 +76,7 @@ export def "nuenv allow" [] {
info "has been allowed"
}

# removes `./.env.nu` from the list of allowed "env" files
export def "nuenv disallow" [] {
check-env-file

Expand Down

0 comments on commit e319652

Please sign in to comment.