From 6d263b78d3992ff23307190c77711f741ed81e96 Mon Sep 17 00:00:00 2001 From: Gregory Gauthier Date: Fri, 6 Feb 2026 15:57:59 +0000 Subject: [PATCH] add script to generate new projects --- jcl/TEMPLATE.jcl | 5 ++++ newjob.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 jcl/TEMPLATE.jcl create mode 100755 newjob.sh diff --git a/jcl/TEMPLATE.jcl b/jcl/TEMPLATE.jcl new file mode 100644 index 0000000..b4eca76 --- /dev/null +++ b/jcl/TEMPLATE.jcl @@ -0,0 +1,5 @@ +//{NAME} JOB (GCC),'C Program', +// NOTIFY=@05054,CLASS=A,MSGCLASS=H, +// MSGLEVEL=(1,1),REGION=4M,TIME=1440 +//STEP1 EXEC GCCCG,INFILE='@05054.SRCLIB.C({NAME})' +// \ No newline at end of file diff --git a/newjob.sh b/newjob.sh new file mode 100755 index 0000000..5803cc6 --- /dev/null +++ b/newjob.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +# Script to create a new C project with JCL and source file +# Usage: ./newjob.sh +# NAME must be 8 characters or less (MVS member name restriction) + +set -e + +if [ $# -ne 1 ]; then + echo "Usage: $0 " + echo " NAME: 8 characters or less (will be uppercased for MVS)" + echo "" + echo "Example:" + echo " $0 hello" + exit 1 +fi + +NAME_INPUT="$1" +NAME=$(echo "$NAME_INPUT" | tr '[:lower:]' '[:upper:]') + +# Validate name length (MVS member names are max 8 characters) +if [ ${#NAME} -gt 8 ]; then + echo "Error: Name '$NAME' is longer than 8 characters (${#NAME} chars)" + echo "MVS member names must be 8 characters or less" + exit 1 +fi + +# Validate name format (alphanumeric, must start with letter) +if ! [[ "$NAME" =~ ^[A-Z][A-Z0-9]*$ ]]; then + echo "Error: Name '$NAME' must start with a letter and contain only letters and numbers" + exit 1 +fi + +JCL_FILE="jcl/${NAME}.jcl" +SRC_FILE="src/${NAME}.c" + +# Check if files already exist +if [ -f "$JCL_FILE" ]; then + echo "Error: JCL file '$JCL_FILE' already exists" + exit 1 +fi + +if [ -f "$SRC_FILE" ]; then + echo "Error: Source file '$SRC_FILE' already exists" + exit 1 +fi + +# Create JCL from template +if [ ! -f "jcl/TEMPLATE.jcl" ]; then + echo "Error: Template file 'jcl/TEMPLATE.jcl' not found" + exit 1 +fi + +echo "Creating new C project: $NAME" +echo "" + +# Replace {NAME} placeholders in template +sed "s/{NAME}/$NAME/g" jcl/TEMPLATE.jcl > "$JCL_FILE" +echo "✓ Created JCL: $JCL_FILE" + +# Create empty C source file +touch "$SRC_FILE" +echo "✓ Created source: $SRC_FILE" + +echo "" +echo "Project '$NAME' created successfully!" +echo "Next steps:" +echo " 1. Edit $SRC_FILE with your C code" +echo " 2. Commit and push to trigger mainframe build"