Skip to content

Commit

Permalink
feat(justfile): ✨ Add some useful checks for inputs.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguest75 committed May 9, 2024
1 parent 2f7e33f commit 91d3b0b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions 75_just/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ just -f ./example.justfile silentecho

# show envvars
just -f ./example.justfile echovars

# checks and confirmation
just -f ./example.justfile folders

```

### Docker Example
Expand Down
25 changes: 24 additions & 1 deletion 75_just/example.justfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
set dotenv-load := true

export WORLD := "world"

# default lists actions
default:
@just -f example.justfile --list

# echo with default parameters
# echo with default parameters
echo param1="defaultvalue1" param2="defaultvalue2":
echo "This echoes $0, {{ param1 }}, {{ param2 }}"

Expand All @@ -17,3 +19,24 @@ echovars:
@echo "EXAMPLE_VAR1=${EXAMPLE_VAR1}"
@echo "EXAMPLE_VAR2=${EXAMPLE_VAR2}"

# check if AWS_PROFILE and AWS_REGION are set
checks:
[ ! -z "${AWS_PROFILE-}" ] || (echo "AWS_PROFILE is not set"; exit 1)
[ ! -z "${AWS_REGION-}" ] || (echo "AWS_REGION is not set"; exit 1)

[confirm("Are you sure you want to delete everything?")]
folders: checks
#!/usr/bin/env bash
echo '{{invocation_directory()}}'
echo '{{justfile_directory()}}'
pwd
if [ -d './test' ]; then
echo 'True!'
rm -rf './test'
fi
echo "This is an {{arch()}} machine".
echo "AWS_PROFILE=${AWS_PROFILE}"
echo "AWS_REGION=${AWS_REGION}"
#export


0 comments on commit 91d3b0b

Please sign in to comment.