Update post2blog.sh
add choosen for multiply repository locations
This commit is contained in:
parent
52681fcbe5
commit
559b238897
15
post2blog.sh
15
post2blog.sh
@ -81,10 +81,11 @@ function dispOptionShort(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#change initial parameters depending on your own file system
|
#change initial parameters depending on your own file system
|
||||||
_repository_address="/Users/zhangyi/Code/GitHub/YiZhangCUG.github.io"
|
_my_repository_addresses=("/Users/zhangyi/Code/GitHub/YiZhangCUG.github.io" "/Users/zhangyi/Documents/GitHub/YiZhangCUG.github.io")
|
||||||
|
_repository_address=${_my_repository_addresses[0]}
|
||||||
_posts_address="_posts/" #directory of your posts
|
_posts_address="_posts/" #directory of your posts
|
||||||
_assets_address="assets/" #directory of your assets
|
_assets_address="assets/" #directory of your assets
|
||||||
_posts_sub_address="2018/" #sub-directory of your posts
|
_posts_sub_address=`date +"%Y-%m/"` #sub-directory of your posts
|
||||||
_mfile='README.md' #default input filename
|
_mfile='README.md' #default input filename
|
||||||
_layout='post' #default post layout
|
_layout='post' #default post layout
|
||||||
_categories='Null' #default category
|
_categories='Null' #default category
|
||||||
@ -99,8 +100,9 @@ _outfile_end='Null'
|
|||||||
_savefile=0
|
_savefile=0
|
||||||
_link_string=""
|
_link_string=""
|
||||||
_no_questions=0
|
_no_questions=0
|
||||||
|
_repository_id=0
|
||||||
#get arguments from terminal
|
#get arguments from terminal
|
||||||
while getopts "hSVi:l:T:c:t:s:" arg
|
while getopts "hSVi:l:T:c:t:s:r:" arg
|
||||||
do
|
do
|
||||||
case $arg in
|
case $arg in
|
||||||
h)
|
h)
|
||||||
@ -115,6 +117,7 @@ do
|
|||||||
dispOptionShort "-s" "Sub-directory of the posts. The main directory of the posts is placed under '${_posts_address}' folder of your github.io directory. The default is '${_posts_sub_address}'."
|
dispOptionShort "-s" "Sub-directory of the posts. The main directory of the posts is placed under '${_posts_address}' folder of your github.io directory. The default is '${_posts_sub_address}'."
|
||||||
dispOptionShort "-S" "Save output markdown file. The default will remove the output file after committing the blog to Github."
|
dispOptionShort "-S" "Save output markdown file. The default will remove the output file after committing the blog to Github."
|
||||||
dispOptionShort "-V" "Don't ask me questions."
|
dispOptionShort "-V" "Don't ask me questions."
|
||||||
|
dispOptionShort "-r" "choose repository your want to use, The default will use the first one."
|
||||||
dispOptionShort "-h" "Show help information."
|
dispOptionShort "-h" "Show help information."
|
||||||
exit 0;;
|
exit 0;;
|
||||||
i)
|
i)
|
||||||
@ -133,6 +136,8 @@ do
|
|||||||
_savefile=1;;
|
_savefile=1;;
|
||||||
V)
|
V)
|
||||||
_no_questions=1;;
|
_no_questions=1;;
|
||||||
|
r)
|
||||||
|
_repository_id=$OPTARG;;
|
||||||
?)
|
?)
|
||||||
printf "\e[1m\e[31mError ==>\e[0m Unknow argument.\n"
|
printf "\e[1m\e[31mError ==>\e[0m Unknow argument.\n"
|
||||||
printf "Use -h option to see help information.\n"
|
printf "Use -h option to see help information.\n"
|
||||||
@ -140,6 +145,10 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ ${_repository_id} != 0 ]]; then
|
||||||
|
_repository_address=${_my_repository_addresses[${_repository_id}]}
|
||||||
|
fi
|
||||||
|
|
||||||
#check if _title is set or not. If so, skip getting _title and _outfile_end from the input file
|
#check if _title is set or not. If so, skip getting _title and _outfile_end from the input file
|
||||||
if [[ ${_title} != 'Null' ]]; then
|
if [[ ${_title} != 'Null' ]]; then
|
||||||
#read input file and put it into a temporary file
|
#read input file and put it into a temporary file
|
||||||
|
Loading…
Reference in New Issue
Block a user