Check to be in Isidore project.

This commit is contained in:
Nicolás A. Ortega Froysa 2022-10-29 14:16:07 +02:00
parent 6fe2659e92
commit b06f2b1a1c

View File

@ -16,6 +16,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
ISIDORE_VERSION="0.1.0"
ISIDORE_CONFIG_DIR=""
ISIDORE_CONFIG_DIR_OPTIONS=(
"$XDG_CONFIG_HOME/isidore"
@ -75,6 +76,18 @@ function print_usage()
echo "USAGE: $1 <command> [options]"
}
##
# Check to see if at the root of an Isidore project.
##
function check_in_project()
{
if ! [ -f "./config.php" ] || ! [ -f "./.isidore-version" ]
then
echo "ERROR: You are not currently in the root of an Isidore project."
exit 1
fi
}
##
# Create a new project.
#
@ -94,6 +107,7 @@ function new_project()
\$site_name = \"$NEW_PROJECT_NAME\";
\$author = \"$ISIDORE_AUTHOR_NAME\";
?>" >> $NEW_PROJECT_DIR/config.php
echo "$ISIDORE_VERSION" > $NEW_PROJECT_DIR/.isidore-version
}
##
@ -101,8 +115,11 @@ function new_project()
##
function clean_project()
{
# TODO: Ensure that this is within an Isidore project.
rm -r output/
check_in_project
if [ -d "./output/" ]
then
rm -r ./output/
fi
echo "Project cleaned."
}