Add getsharelink function to aoc
This commit is contained in:
parent
8f97185c39
commit
79534c356b
32
sbin/aoc
32
sbin/aoc
@ -11,23 +11,34 @@ today() {
|
|||||||
cd $TODAYDIR
|
cd $TODAYDIR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getsharelink() {
|
||||||
|
echo "Getting share path"
|
||||||
|
YR=$CURRYEAR
|
||||||
|
DY=$CURRDAY
|
||||||
|
|
||||||
|
PWD=$(pwd)
|
||||||
|
PWD=${PWD#$AOCROOT/}
|
||||||
|
if [[ "$PWD" =~ ^[1-9][0-9]{3}/day[0-2][0-9]$ ]]; then
|
||||||
|
YR=${PWD:0:4}
|
||||||
|
DY=${PWD:5:5}
|
||||||
|
DY=${DY/day/}
|
||||||
|
fi
|
||||||
|
echo "https://git.bullercodeworks.com/brian/adventofcode/src/branch/main/$YR/day$DY/main.go"
|
||||||
|
}
|
||||||
|
|
||||||
getproblem() {
|
getproblem() {
|
||||||
YR=$CURRYEAR
|
YR=$CURRYEAR
|
||||||
DY=$CURRDAY
|
DY=$CURRDAY
|
||||||
|
|
||||||
PWD=$(pwd)
|
PWD=$(pwd)
|
||||||
PWD=${PWD#$AOCROOT/}
|
PWD=${PWD#$AOCROOT/}
|
||||||
echo $PWD
|
|
||||||
if [[ "$PWD" =~ ^[1-9][0-9]{3}/day[0-2][0-9]$ ]]; then
|
if [[ "$PWD" =~ ^[1-9][0-9]{3}/day[0-2][0-9]$ ]]; then
|
||||||
YR=${PWD:0:4}
|
YR=${PWD:0:4}
|
||||||
DY=${PWD:5:5}
|
DY=${PWD:5:5}
|
||||||
DY=${DY/day0/}
|
DY=${DY/day0/}
|
||||||
DY=${DY/day/}
|
DY=${DY/day/}
|
||||||
else
|
|
||||||
echo "Changing to Today's Directory"
|
|
||||||
cd $AOCROOT/$YR/day$DY
|
|
||||||
fi
|
fi
|
||||||
|
cd "$AOCROOT/$YR/day$DY"
|
||||||
if [[ -f "problem" ]]; then
|
if [[ -f "problem" ]]; then
|
||||||
echo "Found problem file."
|
echo "Found problem file."
|
||||||
if [[ $1 != "-f" ]]; then
|
if [[ $1 != "-f" ]]; then
|
||||||
@ -40,7 +51,7 @@ getproblem() {
|
|||||||
# Remove any zero padding from day
|
# Remove any zero padding from day
|
||||||
DY=$(echo "$CURRDAY"|awk '$0*=1')
|
DY=$(echo "$CURRDAY"|awk '$0*=1')
|
||||||
echo "Getting problem at $CURRYEAR/day/$DY"
|
echo "Getting problem at $CURRYEAR/day/$DY"
|
||||||
elinks -dump https://adventofcode.com/$CURRYEAR/day/$DY > problem
|
# elinks -dump https://adventofcode.com/$CURRYEAR/day/$DY > problem
|
||||||
vim problem
|
vim problem
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,9 +69,15 @@ help() {
|
|||||||
echo "Available Options:"
|
echo "Available Options:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " getproblem - Retrieve the problem for the day associated with the current directory"
|
echo " getproblem - Retrieve the problem for the day associated with the current directory"
|
||||||
|
echo " If the current directory isn't a specific problem (\d\d\d\d/day\d\d/)"
|
||||||
|
echo " then it changes to today's directory, making it if needed"
|
||||||
echo ""
|
echo ""
|
||||||
echo " getsessiontoken - Echo the session token from the elinks cookie file"
|
echo " getsessiontoken - Echo the session token from the elinks cookie file"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo " getsharelink - Get the repo remote path for the main.go file in the current directory"
|
||||||
|
echo " If the current directory isn't a specific problem (\d\d\d\d/day\d\d/)"
|
||||||
|
echo " then it uses today's directory"
|
||||||
|
echo ""
|
||||||
echo " help - Display this message"
|
echo " help - Display this message"
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
@ -72,6 +89,9 @@ case $1 in
|
|||||||
"getsessiontoken")
|
"getsessiontoken")
|
||||||
getsessiontoken
|
getsessiontoken
|
||||||
;;
|
;;
|
||||||
|
"getsharelink")
|
||||||
|
getsharelink
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
help
|
help
|
||||||
;;
|
;;
|
||||||
|
Loading…
Reference in New Issue
Block a user