code

2016年5月17日 星期二

專案指令清單

總是會有人問這些問題,「怎麼打包」、「怎麼deploy」、[怎麼跑測試]
簡單的建立一個指令清單解決所有問題


以下指指執行於ubuntu 14.04 + python 2.7,其它系統可自行微調,差別應該不大
$touch run.py
$chmod +x run.py


修改 run.py 內容
#!/usr/bin/python
#coding=utf-8

import os

cmd = [[
"cd project; mvn clean install ",
"cd project; mvn clean install -Dmaven.test.skip=true",
"cd ~/tomcat/bin;./tomcat.sh", ],
["註解1","打包跳過測試ooxx","desc3"]]

for idx, x in enumerate(cmd[0]): 
 print('\033[9{3}m {0}:{1:55}   {0}\033[0m#{2}').format(idx, x[:55], cmd[1][idx], idx % 7)

userInput = raw_input("run: ")

try:
 print "run:", cmd[0][int(userInput)]
 os.system(cmd[0][int(userInput)])
except Exception, e:
 print "incorrect input"


修改自行需要的指令及註解就行,指令及註解需要成對
程式中{1:55}中的55是顯示指令的寬度,也可以自行調整
色碼變化是依指令數量改變的,有研究bbs色碼的高手可自行修改
也可以拿掉所有 \033[...m  去掉顏色
執行結果如下,輸入數字就可以執行想執行的指令


沒有留言:

張貼留言

想告訴我什麼都可以留言