1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

kh2reg.py: add -o option to write output to a file.

Generally useful, I always think.
This commit is contained in:
Simon Tatham 2019-04-21 14:09:45 +01:00
parent ac1dd1bd2e
commit 0842d4627e

View File

@ -382,12 +382,15 @@ def main():
"--unix", action='store_const',
dest="output_formatter_class", const=UnixOutputFormatter,
help="Produce a file suitable for use as ~/.putty/sshhostkeys.")
parser.add_argument("-o", "--output", type=argparse.FileType("w"),
default=argparse.FileType("w")("-"),
help="Output file to write to (default stdout).")
parser.add_argument("infile", nargs="*",
help="Input file(s) to read from (default stdin).")
parser.set_defaults(output_formatter_class=WindowsOutputFormatter)
args = parser.parse_args()
output_formatter = args.output_formatter_class(sys.stdout)
output_formatter = args.output_formatter_class(args.output)
output_formatter.header()
for line in fileinput.input(args.infile):
handle_line(line, output_formatter)