This commit is contained in:
Ville Rantanen
2016-06-17 14:58:24 +03:00
parent 306b56f8dc
commit 4a83e624b2
2 changed files with 9 additions and 2 deletions

View File

@@ -32,6 +32,8 @@ Special syntaxes:
help="Disable color.") help="Disable color.")
parser.add_argument("-z",action="store_true",dest="zero",default=False, parser.add_argument("-z",action="store_true",dest="zero",default=False,
help="Reset coloring at the end of each line.") help="Reset coloring at the end of each line.")
parser.add_argument("-Z",action="store_false",dest="zero_final",default=True,
help="Disable reset of colors at the end of file.")
parser.add_argument("filename",type=str, parser.add_argument("filename",type=str,
help="File to show, - for stdin") help="File to show, - for stdin")
opts=parser.parse_args() opts=parser.parse_args()
@@ -164,6 +166,7 @@ inlines=['bold1','bold2','code_special','code','image','link','underline','strik
if __name__ == "__main__": if __name__ == "__main__":
opts=setup_options() opts=setup_options()
bc=ansi.code()
if opts.filename=="-": if opts.filename=="-":
f=sys.stdin f=sys.stdin
else: else:
@@ -183,5 +186,6 @@ if __name__ == "__main__":
if opts.zero: if opts.zero:
sys.stdout.write(bc.Z) sys.stdout.write(bc.Z)
sys.stdout.write("\n") sys.stdout.write("\n")
if opts.zero_final:
sys.stdout.write(bc.Z.encode('utf-8'))

View File

@@ -45,6 +45,8 @@ Special syntaxes:
help="Disable color.") help="Disable color.")
parser.add_argument("-z",action="store_true",dest="zero",default=False, parser.add_argument("-z",action="store_true",dest="zero",default=False,
help="Reset coloring at the end of each line.") help="Reset coloring at the end of each line.")
parser.add_argument("-Z",action="store_false",dest="zero_final",default=True,
help="Disable reset of colors at the end of file.")
parser.add_argument("filename",type=str, parser.add_argument("filename",type=str,
help="File to show, - for stdin") help="File to show, - for stdin")
opts=parser.parse_args() opts=parser.parse_args()
@@ -68,5 +70,6 @@ for row in f:
if opts.zero: if opts.zero:
sys.stdout.write(bc.Z) sys.stdout.write(bc.Z)
sys.stdout.write("\n") sys.stdout.write("\n")
if opts.zero_final:
sys.stdout.write(bc.Z.encode('utf-8'))