Skip to content

Instantly share code, notes, and snippets.

@ready4god2513
Created April 20, 2010 03:47
Show Gist options
  • Select an option

  • Save ready4god2513/372002 to your computer and use it in GitHub Desktop.

Select an option

Save ready4god2513/372002 to your computer and use it in GitHub Desktop.
#!/bin/sh
# THE PROBLEM HERE IS THAT WITHOUT HARD-CODING THE PATH
# IT MAY HAVE SOME ISSUES.
BASEPATH=$PWD
# THE BASIC ACTIONS
actions=( index new_one create edit update delete )
createController()
{
# WE REALLY ONLY WANT TO CREATE THIS DIRECTORY IF THERE IS A "/" IN "$1"
mkdir "$BASEPATH/application/controllers/$1"
echo "Creating the controller now"
# ONLY CREATE THIS FILE IF IT DOES NOT ALREADY EXIST.
# IF WE COULD PUT THE 7 BASIC ACTIONS IN, THAT WOULD BE AWESOME.
> "$BASEPATH/application/controllers/$1.php"
}
createViews()
{
mkdir "$BASEPATH/application/views/$1"
for action in ${actions[@]}
do
echo "Creating $1/$action"
echo "<?php /* $1/$action */\n" > "$BASEPATH/application/views/$1/$action.php"
done
}
createController $1
createViews $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment