public static function scaffold($tables = null)
	{
		// do we have any tables defined?
		if (empty($tables))
		{
			// do we want to generate for all tables?
			if ( ! \Cli::option('all', false))
			{
				\Cli::write('No table names specified to run scaffolding on.', 'red');
				exit();
			}

			// get the list of all available tables
			try
			{
				$list = \DB::list_tables(null, \Cli::option('db', null));
			}
			catch (\FuelException $e)
			{
				\Cli::write('The database driver configured does not support listing tables. Please specify them manually.', 'red');
				exit();
			}

			$prefix = \DB::table_prefix();
			$migration = \Config::get('migrations.table', 'migration');

			$tables = array();

			// create the table list
			foreach ($list as $table)
			{
				// strip any defined table prefix from the table name
				if ( ! empty($prefix) and strpos($table, $prefix) === 0)
				{
					$table = substr($table, strlen($prefix));
				}

				// skip the migration table
				$table == $migration or $tables[] = $table;
			}
		}

		// make sure we have an array to work with
		is_array($tables) or $tables = explode(',', $tables);

		// check what kind of models we need to generate
		$subfolder = \Cli::option('crud') ? 'crud' : 'orm';

		// generate for each table defined
		foreach ($tables as $table)
		{
			// start with an empty list
			\Oil\Generate::$create_files = array();

			// and generate
			if (\Cli::option('admin', \Cli::option('a', false)))
			{
				call_user_func('\\Oil\\Generate_Admin::forge', static::arguments($table), $subfolder);
			}
			else
			{
				call_user_func('\\Oil\\Generate_Scaffold::forge', static::arguments($table), $subfolder);
			}
		}
	}