aboutsummaryrefslogtreecommitdiff
path: root/v2/src/bin
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-09-02 12:53:00 -0300
committerEuAndreh <eu@euandre.org>2022-09-02 12:53:00 -0300
commit4bfa46a2fb0c1c33bc090a0900cf729317b5d092 (patch)
tree1673e5c50c988b85ff1cb66ac196179606e94857 /v2/src/bin
parentGenerate .entry-content and .entry-env when building HTML (diff)
downloadeuandre.org-4bfa46a2fb0c1c33bc090a0900cf729317b5d092.tar.gz
euandre.org-4bfa46a2fb0c1c33bc090a0900cf729317b5d092.tar.xz
v2/src/bin/extract: Include FILENAME as an argument (and output)
Diffstat (limited to '')
-rwxr-xr-xv2/src/bin/extract18
1 files changed, 12 insertions, 6 deletions
diff --git a/v2/src/bin/extract b/v2/src/bin/extract
index ce4b115..4380be7 100755
--- a/v2/src/bin/extract
+++ b/v2/src/bin/extract
@@ -5,7 +5,7 @@ set -eu
usage() {
cat <<-'EOF'
Usage:
- extract -t TYPE < STDIN
+ extract -t TYPE FILENAME
extract -h
EOF
}
@@ -17,21 +17,24 @@ help() {
-t TYPE the type of extraction to perform ("content" or "env")
-h, --help show this message
+ FILENAME the name of the input file, also to be used as
+ URL.
+
Separate the content from the "frontmatter", and emit the
- selected one.
+ selected one, given the FILENAME.
Examples:
Get the content:
- $ extract -t content < src/file.md > src/file.entry-content
+ $ extract -t content src/file.md > src/file.entry-content
Get the "frontmatter":
- $ extract -t env < src/f.md > src/f.entry-env
+ $ extract -t env src/f.md > src/f.entry-env
EOF
}
@@ -71,6 +74,8 @@ done
shift $((OPTIND - 1))
+FILENAME="${1:-}"
+eval "$(assert-arg "$FILENAME" 'FILENAME')"
eval "$(assert-arg "$TYPE" '-t TYPE')"
@@ -79,7 +84,7 @@ case "$TYPE" in
awk '
separator >= 2
/^---$/ { separator++ }
- '
+ ' "$FILENAME"
;;
env)
awk '
@@ -92,7 +97,8 @@ case "$TYPE" in
}
{ print }
- '
+ ' "$FILENAME"
+ printf "FILENAME='%s'\n" "$FILENAME"
;;
*)
printf 'Bad value for TYPE: "%s".\n\n' \