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

[pull] master from chubin:master #91

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/tests-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: MacOS Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- run: ./share/adapters/rfc.sh
5 changes: 3 additions & 2 deletions .github/workflows/tests-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: ./share/adapters/rfc.sh
- name: install dependencies
run: pip install --upgrade -r requirements.txt
- name: fetch upstream cheat sheets
Expand Down
22 changes: 15 additions & 7 deletions share/adapters/rfc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ RFC_get()
| sed 's/##/\n/g' \
| sed 's/# //g' \
| grep -o '.*\. ' \
| sed -r 's/^(.*)(January|February|March|April|May|June|July|August|September|October|November|December) [[:digit:]]{4}(.*)$/\1/'
| sed -E 's/^(.*)(January|February|March|April|May|June|July|August|September|October|November|December) [[:digit:]]{4}(.*)$/\1/'
}

UNAME=$(uname -s)
if [ "$UNAME" = "Darwin" ]; then
SED_I="sed -i ''"
else
SED_I="sed -i"
fi

mkdir -p /tmp/RFC_get
local WEB_RESP="/tmp/RFC_get/rfc_get_web_resp_${RANDOM}.html"
local RFC_INDEX="/tmp/RFC_get/rfc_index.html"
Expand All @@ -23,9 +30,11 @@ RFC_get()
[ -f ${RFC_INDEX} ] || curl 'https://www.ietf.org/download/rfc-index.txt' 2>/dev/null > ${RFC_INDEX}
local MIN_RFC=1
local MAX_RFC=$(sed '/^ / d' ${RFC_INDEX} | tail -n 1 | sed 's/ .*//')


local arg_lower=$(echo "$1" | tr '[:upper:]' '[:lower:]')

# Syntax check Usage statement
if [ $# -lt 1 ] || [[ ${1,,} == "-h" ]] || [[ ${1,,} == "--help" ]] || [[ ${1,,} == ":help" ]] || [[ ${1,,} == ":usage" ]]
if [ $# -lt 1 ] || [ "$arg_lower" = "-h" ] || [ "$arg_lower" = "--help" ] || [ "$arg_lower" = ":help" ] || [ "$arg_lower" = ":usage" ]
then
printf "
USAGE:
Expand Down Expand Up @@ -80,15 +89,15 @@ RFC_get()
fi
fi
# Print list of available RFCs
elif [[ "${1,,}" == ":list" ]]
elif [ "$arg_lower" = ":list" ]
then
# Format RFC_INDEX to show short description of each RFC
rfc_describe \
| grep -v 'Not Issued' \
| sed 's/ .*//; s/^0*//'
return 0
# Print list of available RFCs
elif [[ "${1,,}" == ":describe" ]]
elif [ "$arg_lower" = ":describe" ]
then
# Format RFC_INDEX to show short description of each RFC
rfc_describe
Expand All @@ -101,7 +110,7 @@ RFC_get()
> $WEB_RESP
fi
# Format nicely and print
sed -i '/Page [0-9]/,+2d; /page [0-9]/,+2d' ${WEB_RESP}
$SED_I -e '/Page [0-9]/,+2d; /page [0-9]/,+2d' ${WEB_RESP}
if grep -q '<!DOCTYPE html>' ${WEB_RESP}
then
echo "Error retrieving RFC $1"
Expand All @@ -112,5 +121,4 @@ RFC_get()
return 0
fi
)

RFC_get "$1"