Last active
March 16, 2019 17:21
-
-
Save liuchong/893e3149f4326b449569386fdd076210 to your computer and use it in GitHub Desktop.
啦啦啦……
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| PUSH=false | |
| DT=`date --rfc-3339=date` | |
| MAX=36666 | |
| punch() { | |
| cur=-1 | |
| while [ $((++cur)) -lt $MAX ]; do | |
| echo -e "\n$DT" >> punch.txt | |
| git add punch.txt | |
| git commit -m "$DT" --date="$DT" | |
| DT=`date -d "$DT +1 days" --rfc-3339=date` | |
| done | |
| } | |
| push() { | |
| $PUSH && git push | |
| } | |
| main() { | |
| punch | |
| push | |
| } | |
| usage() { | |
| echo -e "Usage: | |
| -d [yyyy-mm-dd] specify date | |
| -m [number] max days, default 36666 | |
| -p push to remote" | |
| } | |
| # Main | |
| while getopts 'd:m:ph' OPT; do | |
| case $OPT in | |
| d) | |
| DT=$(date -d "$OPTARG" --rfc-3339=date) | |
| [ $? -ne 0 ] && exit 1 | |
| ;; | |
| m) | |
| MAX="$OPTARG" | |
| ;; | |
| p) | |
| PUSH=true | |
| ;; | |
| h) | |
| usage; exit 0 | |
| ;; | |
| ?) | |
| usage | |
| exit 1 | |
| ;; | |
| esac | |
| done | |
| shift $(($OPTIND - 1)) | |
| main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment