소스 검색

changed to a directory oriented command line
prepare for side-by-side directory compare (like wdrm)

Pat Beirne 9 년 전
부모
커밋
87d6c48ede
1개의 변경된 파일12개의 추가작업 그리고 7개의 파일을 삭제
  1. 12 7
      dirnotes

+ 12 - 7
dirnotes

@@ -13,14 +13,15 @@ these comments stick to the symlink
 
 """
 
-COMMENT_KEY = "user.xdg.comment"
-DATABASE_NAME = "~/.dirnotes.db"
-
 import sys,os,argparse
 from PyQt4.QtGui import *
 from PyQt4 import QtGui, QtCore
 import xattr, sqlite3, time
 
+VERSION = "0.2"
+COMMENT_KEY = "user.xdg.comment"
+DATABASE_NAME = "~/.dirnotes.db"
+# convert the ~/ form to a fully qualified path
 DATABASE_NAME = os.path.expanduser(DATABASE_NAME)
 
 class DataBase:
@@ -61,11 +62,15 @@ class DataBase:
 
 def parse():
 	parser = argparse.ArgumentParser(description='dirnotes application')
-	parser.add_argument('filename',metavar='filename',type=str,
-		nargs="*",help='filename or directory',default=".")
+	parser.add_argument('dirname',metavar='dirname',type=str,
+		help='directory [default=current dir]',default=".",nargs='?')
+	parser.add_argument('dirname2',help='comparison directory, shows two-dirs side-by-side',nargs='?')
 	parser.add_argument('-n','--nogui',action="store_const",const="1",
 		help='use text base interface')
-	parser.add_argument('-v','--version',action='version',version='%(prog)s 0.2')
+	parser.add_argument('-v','--version',action='version',version='%(prog)s '+VERSION)
+	group = parser.add_mutually_exclusive_group()
+	group.add_argument('-s','--sort-by-name',metavar='sort',action="store_const",const='n')
+	group.add_argument('-m','--sort-by-date',metavar='sort',action='store_const',const='d')
 	return parser.parse_args()
 
 def debug(x):
@@ -157,7 +162,7 @@ if __name__=="__main__":
 	print(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(d)))
 
 	a = QApplication([])
-	dn = DirNotes(p.filename[0])
+	dn = DirNotes(p.dirname[0])
 	dn.show()
 	
 	a.exec_()