pcreate
Table of Contents
Introduction
Yet another old utility I wrote, this time to allow me to generate projects back when all my projects were both small and pretty simple.
It's also interesting to note the inversion. Previously I would have autodoc generate the documentation (READMEs and so on) from the code. Now I have the documentation generate the code.
makefile
PROGRAM_NAME = "tslides" RESOURCES_DIR = $(HOME)/.resources BIN_INSTALL_DIR = $(HOME)/bin install: mkdir -p $(RESOURCES_DIR)/$(PROGRAM_NAME) cp -r resources/* $(RESOURCES_DIR)/$(PROGRAM_NAME) cp -r main.sh $(BIN_INSTALL_DIR)/$(PROGRAM_NAME) uninstall: rm -rf $(RESOURCES_DIR)/$(PROGRAM_NAME) rm $(BIN_INSTALL_DIR)/$(PROGRAM_NAME) document: autodoc main.sh
main.sh
#!/bin/bash : ' @filename: pcreate @repository: nil @creator: nil @description A simple script to create and configure basic install scripts in new projects. USAGE: pcreate PROJECT_NAME OPTIONS OPTIONS: -c standard program in c -c++ standard program in C++ -e --elixir standard program in elixir -o --other standard program with no specified language -h --haskell standard program in haskell -t --typescript standard program written in typescript -b --bash utility written in bash with install script -cu --c-utility utility written in c with install script -tu --typescript-utility utility written in typescript with install script @description @dependancies: bash, git ' # ==================== CONSTANTS ============================================= HELPMSG="USAGE: pcreate PROJECT_NAME OPTIONS OPTIONS: -c standard program in c -c++ standard program in C++ -e --elixir standard program in elixir -o --other standard program with no specified language -h --haskell standard program in haskell -r --rust standard program in rust -t --typescript standard program written in typescript -b --bash utility written in bash with install script -cu --c-utility utility written in c with install script -ru --rust-utility utility written in rust with install script -tu --typescript-utility utility written in typescript with install script " GITIGNORE="https://gist.githubusercontent.com/Alexandra-Miller/b47139749f861f02d3176f57f17626ce/raw/160e75b70f51c2c5ef5201735f0d457abadf829d/.gitignore" STANDARD_HEADER=" @project: $1 @repo: https://github.com/Alexandra-Miller/$1 @creator: Alexandra Marie Miller @description @description @deps: " RESOURCES_DIR="$HOME/.resources/pcreate/" [ -d "resources" ] && RESOURCES_DIR="resources" # ==================== FUNCTIONS ============================================= # $1 = project name createGit () { ( cd $1 # create README.md echo "# $1" >> README.md read -p "Enter Project Description: " descText echo "$descText" >> README.md # create git repo git init curl $GITIGNORE -o .gitignore # add git files and commit git add . git commit -m "Initial commit" ) } # $1 = project name configMake () { sed -i "s/@@PROJECT@@/$1/g" $1/makefile } # $1 = project name $2 = main filename configFile () { sed -i "s/@@PROJECT@@/$1/g" $1/$2 } # $1 = project name createC () { mkdir $1 cp $RESOURCES_DIR/c/* $1/ configMake $1 configFile $1 main.c } # $1 = project name createCpp () { mkdir $1 cp $RESOURCES_DIR/c++/* $1/ configMake $1 configFile $1 main.cpp } # $1 = project name createElixir () { mkdir $1 cp $RESOURCES_DIR/elixir/* $1/ configMake $1 configFile $1 main.ex } # $1 = project name createHaskell () { mkdir $1 cp $RESOURCES_DIR/haskell/* $1/ configMake$1 configFile $1 main.hs } # $1 = project name createOther () { mkdir $1 cp $RESOURCES_DIR/other/* $1/ } # $1 = project name createRust () { cargo new $1 cp $RESOURCES_DIR/rust/* $1/ configMake $1 configFile $1/src/main.rs } # $1 = project name createTypescript () { mkdir $1 ( cd $1 npm init npm install ) cp $RESOURCES_DIR/typescript/* $1/ configMake $1 configFile $1 index.ts } # $1 = project name createBash () { mkdir $1 cp $RESOURCES_DIR/bash/* $1/ configMake $1 configFile $1 main.sh } # $1 = project name createCUtil () { mkdir $1 cp $RESOURCES_DIR/c-util/* $1/ configMake $1 configFile $1 main.c } # $1 = project name createRustUtil () { cargo new $1 cp $RESOURCES_DIR/rust-util/* $1/ configMake $1 configFile $1 main.rs } # $1 = project name createTypescriptUtil () { mkdir $1 ( cd $1 npm init npm install ) cp $RESOURCES_DIR/typescript-util/* $1/ configMake $1 configFile $1 index.ts } if [ "$#" == "1" ] then mkdir $1 createOther $1 createGit $1 elif [ "$#" == "2" ] then [ $1 = "-c" ] && createC $2 [ $1 = "-c++" ] && createCpp $2 [ $1 = "--elixir" ] || [ $1 = "-e" ] && createElixir $2 [ $1 = "--haskell" ] || [ $1 = "-h" ] && createHaskell $2 [ $1 = "--other" ] || [ $1 = "-o" ] && createOther $2 [ $1 = "--rust" ] || [ $1 = "-r" ] && createRust $2 [ $1 = "--typescript" ] || [ $1 = "-t" ] && createTypescript $2 [ $1 = "--bash" ] || [ $1 = "-b" ] && createBash $2 [ $1 = "--c-util" ] || [ $1 = "-c" ] && createC $2 [ $1 = "--rust-util" ] || [ $1 = "-ru" ] && createRustUtil $2 [ $1 = "--typescript-util" ] || [ $1 = "-tu" ] && createTypescriptUtil $2 createGit $2 else echo "$HELPMSG" fi