From 31c7578fa1b1545beb65cf504cf58d11251437ff 2022-08-29 18:13:57
From: Branko Majic <branko@majic.rs>
Date: 2022-08-29 18:13:57
Subject: [PATCH] [factorio_development.sh] Make mod directory path optional for init command:

- Default to using the working directory as root.
- Bump the version, initial feature-complete release.

---

diff --git a/games/factorio_development.sh b/games/factorio_development.sh
index ef5cf74c64f4934d840f0a507c7de875b23afeda..99561dfde1784290b63114b3e234dd79e36853ce 100755
--- a/games/factorio_development.sh
+++ b/games/factorio_development.sh
@@ -22,7 +22,7 @@
 set -u
 
 PROGRAM="factorio_development.sh"
-VERSION="0.0.5"
+VERSION="1.0.0"
 
 function usage() {
     cat <<EOF
@@ -30,7 +30,7 @@ $PROGRAM $VERSION, helper tool for development of Factorio mods
 
 Usage:
 
-  $PROGRAM [OPTIONS] init MOD_DIRECTORY_PATH
+  $PROGRAM [OPTIONS] init [MOD_DIRECTORY_PATH]
   $PROGRAM [OPTIONS] build [MOD_DIRECTORY_PATH]
   $PROGRAM [OPTIONS] release [MOD_DIRECTORY_PATH]
   $PROGRAM [OPTIONS] abort-release [MOD_DIRECTORY_PATH]
@@ -79,7 +79,8 @@ init MOD_DIRECTORY_PATH
   Initialises directory for new mod development. Passed-in directory
   must be empty. Mod name is derived from the directory name. If the
   passed-in mod directory path does not point to an existing
-  directory, it will be created.
+  directory, it will be created. If not specified, default is to use
+  working directory as mod directory path.
 
   During initialisation it is possible to select if mod sources should
   be kept in a separate directory or within the base directory. This
@@ -1058,13 +1059,13 @@ shift
 
 if [[ $COMMAND == init ]]; then
 
-    MOD_DIRECTORY_PATH="${1-}"
+    MOD_DIRECTORY_PATH="${1:-.}"
     shift
 
     DEVELOPMENT_SCRIPT_PATH=$(readlink -f "$0")
 
-    if [[ -z $MOD_DIRECTORY_PATH ]]; then
-        error "Mod directory path must be specified."
+    if [[ -e $MOD_DIRECTORY_PATH && ! -d $MOD_DIRECTORY_PATH ]]; then
+        error "Passed-in path must be a directory."
         exit "$ERROR_ARGUMENTS"
     fi