add project initialization feature
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Joe 2020-11-19 17:13:22 -06:00
parent f1d8002072
commit acb985eb42
Signed by: joe
GPG Key ID: 8595A3F8F2CE1B74
3 changed files with 88 additions and 0 deletions

44
linac
View File

@ -44,6 +44,50 @@ BuildProject() {
done > "${config[build_path]}$1.sh"
AddShebang "$1"
}
InitProject() {
available_licenses=('' 'GPLv3' 'Apache License 2.0' 'MIT')
GetInitInfo() {
while [[ -z "$init_name" ]]; do
read -r -p "$(echo -e '\nWhat is the project'\''s name? ')" init_name
done
read -r -p "$(echo -e '\nPlease enter a description for the project. ')" init_description
read -r -p "$(echo -e '\nWho is the project'\''s author? ')" init_author
echo -e '\nPlease select a license for the project:\n'
for ((i=1;i<"${#available_licenses[*]}";i++)); do
echo -e " [$i] ${available_licenses[$i]}"
done
read -r -p "" init_license_num
init_license=${available_licenses[$init_license_num]}
WriteInitInfo
}
WriteInitInfo() {
echo -e "projectName=$init_name" > "$init_name.info"
{
echo -e "projectDescription=$init_description"
echo -e "projectAuthor=$init_author"
echo -e "projectLicense=$init_license"
} >> "$init_name.info"
echo -e "# Add build files to this file. One per line." > "$init_name.build"
}
if [[ -f "linac.conf" ]]; then
read -r -p "$(echo -e 'It looks like there is already another LINAC project in this directory! Are you sure you want to initialize a new project? (Y/n) ')" init_confirm
case "$init_confirm" in
[yY]|[Yy][Ee][Ss] ) GetInitInfo;;
[Nn]|[Nn][Oo] ) exit 0;;
* ) exit 0;;
esac
else
GetInitInfo
fi
}
SubInit() {
InitProject
}
SubBuild() {
BuildProject "$1"
}

41
src/InitProject Normal file
View File

@ -0,0 +1,41 @@
InitProject() {
available_licenses=('' 'GPLv3' 'Apache License 2.0' 'MIT')
GetInitInfo() {
while [[ -z "$init_name" ]]; do
read -r -p "$(echo -e '\nWhat is the project'\''s name? ')" init_name
done
read -r -p "$(echo -e '\nPlease enter a description for the project. ')" init_description
read -r -p "$(echo -e '\nWho is the project'\''s author? ')" init_author
echo -e '\nPlease select a license for the project:\n'
for ((i=1;i<"${#available_licenses[*]}";i++)); do
echo -e " [$i] ${available_licenses[$i]}"
done
read -r -p "" init_license_num
init_license=${available_licenses[$init_license_num]}
WriteInitInfo
}
WriteInitInfo() {
echo -e "projectName=$init_name" > "$init_name.info"
{
echo -e "projectDescription=$init_description"
echo -e "projectAuthor=$init_author"
echo -e "projectLicense=$init_license"
} >> "$init_name.info"
echo -e "# Add build files to this file. One per line." > "$init_name.build"
}
if [[ -f "linac.conf" ]]; then
read -r -p "$(echo -e 'It looks like there is already another LINAC project in this directory! Are you sure you want to initialize a new project? (Y/n) ')" init_confirm
case "$init_confirm" in
[yY]|[Yy][Ee][Ss] ) GetInitInfo;;
[Nn]|[Nn][Oo] ) exit 0;;
* ) exit 0;;
esac
else
GetInitInfo
fi
}

3
src/SubInit Normal file
View File

@ -0,0 +1,3 @@
SubInit() {
InitProject
}