update
This commit is contained in:
parent
385d8f675b
commit
01eeb14913
@ -19,8 +19,8 @@ class Entry(namedtuple('Entry', ['host', 'algorithm', 'hash'])):
|
||||
return f'{self.algorithm}{self.separator}{self.hash}'
|
||||
|
||||
|
||||
def main(args):
|
||||
filename: Path = getattr(args, 'known_hosts', Path())
|
||||
def run(args) -> None:
|
||||
filename: Path = getattr(args, 'input', Path())
|
||||
file_path = filename.resolve()
|
||||
if not file_path.is_file():
|
||||
sys.exit(1)
|
||||
@ -84,7 +84,7 @@ def main(args):
|
||||
wfp.writelines(output_lines)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main() -> None:
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
@ -92,12 +92,16 @@ if __name__ == '__main__':
|
||||
)
|
||||
parser.add_argument(
|
||||
'-i',
|
||||
'--known_hosts',
|
||||
'--input',
|
||||
type=Path,
|
||||
default=f"{os.path.expanduser('~')}/.ssh/known_hosts",
|
||||
help='known_hosts file to read',
|
||||
default=f'{os.path.expanduser("~")}/.ssh/known_hosts',
|
||||
help='file to read',
|
||||
)
|
||||
parser.add_argument('-o', '--output', type=Path, help='output file to write')
|
||||
parser.set_defaults(func=main)
|
||||
parser.add_argument('-o', '--output', type=Path, help='file to write')
|
||||
parser.set_defaults(func=run)
|
||||
args = parser.parse_args()
|
||||
args.func(args)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user