Yii2: my Bash Generator

Ini hanya catatan:

#!/bin/bash

input_file="$1"
table_name="$2"
table_model="$3"
table_key="$4"
col_name="$5"

#read -p "Enter your Feature (ex: biodata): " input_file
#read -p "Enter your Table Name (ex: tbl_biodata): " table_name
#read -p "Enter your Table Model (ex: Tbl_biodata): " table_model
#read -p "Enter your Table Key (ex: bio_id): " table_key
#read -p "Enter your one Table Column (ex: fullname): " col_name


output_file="ExampleTest.txt"

# Extract file name without extension
file_name=${input_file%%.*}

# Set first letter to uppercase
first_char=${file_name:0:1}
first_char_upper=$(echo "$first_char" | tr '[:lower:]' '[:upper:]')

# Combine with remaining file name and extension
output_file="$first_char_upper${file_name:1}"
output_file1="$first_char_upper${file_name:1}Controller"

echo "Input file: $input_file"
echo "Output file: $output_file"

cp controllers/TemplateController.php controllers/$output_file1.php

string2='orange'

sed -i "s/Template/$output_file/g" controllers/$output_file1.php
sed -i "s/template/$input_file/g" controllers/$output_file1.php
sed -i "s/table_name/$table_name/g" controllers/$output_file1.php
sed -i "s/table_model/$table_model/g" controllers/$output_file1.php
sed -i "s/table_key/$table_key/g" controllers/$output_file1.php
sed -i "s/col_name/$col_name/g" controllers/$output_file1.php

cp -r views/template_view views/$input_file

sed -i "s/Template/$output_file/g" views/$input_file/index.php
sed -i "s/Template/$output_file/g" views/$input_file/jx_form.php
sed -i "s/template/$input_file/g" views/$input_file/index.php
sed -i "s/template/$input_file/g" views/$input_file/jx_form.php
sed -i "s/table_key/$table_key/g" views/$input_file/index.php
sed -i "s/table_key/$table_key/g" views/$input_file/jx_form.php
sed -i "s/col_name/$col_name/g" views/$input_file/index.php
sed -i "s/col_name/$col_name/g" views/$input_file/jx_form.php
sed -i "s/table_model/$table_model/g" views/$input_file/index.php
sed -i "s/table_model/$table_model/g" views/$input_file/jx_form.php

Leave a comment

I’m Eddy

Dive into my world where every page is a celebration of knowledge, particularly my fascination with computer science. Join me in this journey of exploration and learning—save the day by bookmarking knowledge that spans the breadth of computer science. Enjoy the read, and may each visit offer you something valuable to take away!


Let’s connect