Changeset - 1f5e8e9e79db
[Not reviewed]
0 1 0
Branko Majic (branko) - 20 months ago 2022-08-21 15:58:51
branko@majic.rs
[factorio_development.sh] Include development script in mod directory during initialisation:

- Makes it simpler for people to use the scription without having to
fetch it from external location.
1 file changed with 12 insertions and 2 deletions:
0 comments (0 inline, 0 general)
games/factorio_development.sh
Show inline comments
 
@@ -19,13 +19,13 @@
 
#
 

	
 
# Treat unset variables as errors.
 
set -u
 

	
 
PROGRAM="factorio_development.sh"
 
VERSION="0.0.4"
 
VERSION="0.0.5"
 

	
 
function usage() {
 
    cat <<EOF
 
$PROGRAM $VERSION, helper tool for development of Factorio mods
 

	
 
Usage:
 
@@ -86,12 +86,13 @@ init MOD_DIRECTORY_PATH
 
  can be helpful for separating non-Factorio assets and files (such as
 
  license, README file etc).
 

	
 
  The following files are created as part of the process ([src/]
 
  indicates optional placement under separate source directory):
 

	
 
    - build.sh, factorio_development.sh script itself.
 
    - README.md, provides detailed mod description and information.
 
    - LICENSE, contains license information for the mod.
 
    - .gitignore, for ignoring files and paths when working with git.
 
    - build.cfg, for configuring how the releases are built.
 
    - [src/]info.json, mod metadata.
 
    - [src/]changelog.txt, with changelog information for the mod.
 
@@ -470,17 +471,21 @@ function get_mod_name() {
 
#
 
# Arguments:
 
#
 
#   $1 (base_dir)
 
#     Base directory under which the structure should be created.
 
#
 
#   $2 (development_script)
 
#     Path to build/development script to include in the repository.
 
#
 
# Returns:
 
#   0 on success, 1 otherwise.
 
#
 
function command_init() {
 
    local base_dir="$1"
 
    local development_script="$2"
 

	
 
    local mod_name separate_source source_dir
 

	
 
    # Normalise the path.
 
    base_dir=$(readlink -f "$base_dir")
 

	
 
@@ -514,12 +519,15 @@ function command_init() {
 
        read -r -p "Separate mod source under \"src/\" sub-directory? (y/n) " separate_source
 
    done
 

	
 
    [[ ${separate_source,,} == y ]] && source_dir="$base_dir/src" || source_dir="$base_dir"
 
    mkdir -p "$source_dir"
 

	
 
    # Include the development script itself into the repository (for ease of use).
 
    cp "$development_script" "$base_dir/build.sh"
 

	
 
    # Create initial set of files.
 
    cat <<EOF > "$base_dir/README.md"
 
MOD_TITLE
 
=========
 

	
 

	
 
@@ -1050,18 +1058,20 @@ shift
 

	
 
if [[ $COMMAND == init ]]; then
 

	
 
    MOD_DIRECTORY_PATH="${1-}"
 
    shift
 

	
 
    DEVELOPMENT_SCRIPT_PATH=$(readlink -f "$0")
 

	
 
    if [[ -z $MOD_DIRECTORY_PATH ]]; then
 
        error "Mod directory path must be specified."
 
        exit "$ERROR_ARGUMENTS"
 
    fi
 

	
 
    if ! command_init "$MOD_DIRECTORY_PATH"; then
 
    if ! command_init "$MOD_DIRECTORY_PATH" "$DEVELOPMENT_SCRIPT_PATH"; then
 
        exit "$ERROR_GENERAL"
 
    fi
 

	
 
elif [[ $COMMAND == build ]]; then
 

	
 
    MOD_DIRECTORY_PATH="${1:-.}"
0 comments (0 inline, 0 general)