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