文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>文件模板生成器

文件模板生成器

时间:2007-04-21  来源:ly44770

网上淘来,一个可以生成规格化c,cpp,makefile,shell等文件的脚本,相当不错,我修改了一下自用。

#!/bin/bash
# Filename   : template
# Description: Create a template based on [c | c++ | Makefile | bash | README]
# Author     : ly44770
# Version    : 1.0
# Date       : 2007.4.21

create_c()
{
cat >> $1 << EOF
/*********************************************************************
 * CEAL
 * All rights reserved.
 * Filename   : $TARGET
 * Description:
 * Author     : ly44770
 * Version    :
 * Date       : `date +%Y.%m.%d`
 **********************************************************************/

/*
 * Function   :
 * Description:
 * Parameters :
 * Return     :
 */

EOF
}

create_readme()
{
cat >> $1 << EOF
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#                                                           #
#                        README                             #
#                        ly44770                            #
#                       `date +%Y.%m.%d`                    #
#                                                           #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
EOF
}

create_makefile()
{
cat >> $1 << EOF
# Makefile
 
# Compiler
CC=/usr/local/arm/2.95.3/bin/arm-linux-gcc

# Options
CFLAGS=-D__KERNEL__ -D__MODULE -I -O -Wall

# Source files
SRC=

# Target file
TARGET=

# Run
\$(TARGET): \$(SRC)
    \$(CC) \$(CFLAGS) \$^ -o \$@

# Clean
.PHONY: clean
clean:
    rm -f \$(TARGET)
EOF
}

create_shell()
{
cat >> $1 << EOF
#!/bin/bash
# # Filename   : $TARGET
# Description:
# Author     : ly44770
# Version    :
# Date       : `date +%y.%m.%d`

EOF
    chmod +x $1
}

# First, get parameters and handle error.
if [ $# != 1 ]; then
    echo "Usage: `basename $0` [filename]"
    echo "Support:"
    echo "        [*.c(h|cpp) | Makefile | bash | README]"
    exit 1
else
    TARGET=$1
fi

# Second, create template in terms of TARGET name.
# *.c   --- c program template
# *.cpp --- c++ program template
# other --- bash shell program template
case $TARGET in
*.c|*.cpp|*.h)
    create_c $TARGET
    ;;

README)
    create_readme $TARGET
    ;;

Makefile)
    create_makefile $TARGET
    ;;

*)
    create_shell $TARGET
    ;;
esac
相关阅读 更多 +
排行榜 更多 +
步行僵尸2无限金币版

步行僵尸2无限金币版

体育竞技 下载
狐狸一号特殊任务无限金币版

狐狸一号特殊任务无限金币版

体育竞技 下载
忍者之雷复仇无限金币钻石版

忍者之雷复仇无限金币钻石版

体育竞技 下载