added the automatic search to user on github
This commit is contained in:
parent
dec7358f95
commit
ae5cd66e0b
1 changed files with 18 additions and 11 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
autoload colors
|
autoload colors
|
||||||
colors
|
colors
|
||||||
for COLOR in RED GREE YELLOW BLUE MAGENTA CYAN BLACK WHITE; do
|
for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do
|
||||||
eval $COLOR='$fg_no_bold[${(L)COLOR}]'
|
eval $COLOR='$fg_no_bold[${(L)COLOR}]'
|
||||||
eval BOLD_$COLOR='$fg_bold[${(L)COLOR}]'
|
eval BOLD_$COLOR='$fg_bold[${(L)COLOR}]'
|
||||||
done
|
done
|
||||||
|
@ -11,12 +11,12 @@ eval RESET='$reset_color'
|
||||||
answer=""
|
answer=""
|
||||||
# Capitalize a string
|
# Capitalize a string
|
||||||
capitalize(){
|
capitalize(){
|
||||||
local str="$*"
|
local str="$(print -- "$*" | sed 's/-/ /g')"
|
||||||
print -- ${${str[1]}:u}${str[2,-1]}
|
print -- ${(C)str} | sed 's/ //g'
|
||||||
}
|
}
|
||||||
bk(){print -- "${RED}Bridgekeeper: $*${RESET}"}
|
bk(){print -- "${GREEN}Bridgekeeper: $*${RESET}"}
|
||||||
bkn(){print -n -- "${RED}Bridgekeeper: $*${RESET}"}
|
bkn(){print -n -- "${GREEN}Bridgekeeper: $*${RESET}"}
|
||||||
you(){print -- "${BLUE}You: $*${RESET}"}
|
you(){print -- "${YELLOW}You: $*${RESET}"}
|
||||||
log(){print -- $*}
|
log(){print -- $*}
|
||||||
err(){
|
err(){
|
||||||
{
|
{
|
||||||
|
@ -72,15 +72,19 @@ you "Ask me the questions, bridgekeeper, I am not afraid.\n"
|
||||||
# project name
|
# project name
|
||||||
bk "What is the name of your project?"
|
bk "What is the name of your project?"
|
||||||
print -n "> ";read project
|
print -n "> ";read project
|
||||||
|
project=${${project:gs/ /-/}:l} # use lowercase and replace spaces by dashes
|
||||||
|
print -- DEBUG $project
|
||||||
|
|
||||||
if perl -e 'exit("'$project'" =~ /^[a-zA-Z0-9]*$/)'; then
|
# Verify project has the right format
|
||||||
err "The project name can't contains non ASCII character"
|
if perl -e 'exit("'$project'" =~ /^[a-z][a-z0-9-]*$/)'; then
|
||||||
|
err "The project must start with a letter and contains only letter, number, spaces or dashes"
|
||||||
fi
|
fi
|
||||||
project=${project:l} # use lowercase for project name
|
|
||||||
module=$(capitalize $project)
|
|
||||||
[[ $project = "" ]] && err "Can't use empty project name"
|
[[ $project = "" ]] && err "Can't use empty project name"
|
||||||
[[ -e $project ]] && err "$project directory already exists"
|
[[ -e $project ]] && err "$project directory already exists"
|
||||||
|
|
||||||
|
# Find the main module name from the project name
|
||||||
|
module=$(capitalize $project)
|
||||||
|
|
||||||
# author name
|
# author name
|
||||||
ask name
|
ask name
|
||||||
name="$answer"
|
name="$answer"
|
||||||
|
@ -88,8 +92,11 @@ name="$answer"
|
||||||
ask email
|
ask email
|
||||||
email="$answer"
|
email="$answer"
|
||||||
# github
|
# github
|
||||||
bk "What is your github user name?"
|
bkn "What is your github user name?"
|
||||||
|
githubname="$( curl -sH 'Accept: application/vnd.github.v3.text-match+json' 'https://api.github.com/search/users?q='$email|grep '"login":'|perl -pe 's/.*"([^"]*)",/$1/' )"
|
||||||
|
print -- " ($githubname)"
|
||||||
print -n "> ";read github
|
print -n "> ";read github
|
||||||
|
[[ $github = "" ]] && github=$githubname
|
||||||
# synopsis
|
# synopsis
|
||||||
bk "What is your project in less than ten words?"
|
bk "What is your project in less than ten words?"
|
||||||
print -n "> ";read description
|
print -n "> ";read description
|
||||||
|
|
Loading…
Reference in a new issue