39 lines
968 B
Python
39 lines
968 B
Python
#!/usr/bin/env python3
|
|
import argparse
|
|
|
|
from iottb.subcommands.capture import setup_capture_parser
|
|
from iottb.subcommands.add_device import setup_init_device_root_parser
|
|
|
|
|
|
######################
|
|
# Argparse setup
|
|
######################
|
|
def setup_argparse():
|
|
# create top level parser
|
|
root_parser = argparse.ArgumentParser(prog='iottb')
|
|
subparsers = root_parser.add_subparsers(title='subcommands', required=True, dest='command')
|
|
|
|
setup_capture_parser(subparsers)
|
|
setup_init_device_root_parser(subparsers)
|
|
|
|
return root_parser
|
|
|
|
|
|
def main():
|
|
parser = setup_argparse()
|
|
args = parser.parse_args()
|
|
print(args)
|
|
if args.command:
|
|
try:
|
|
args.func(args)
|
|
except KeyboardInterrupt:
|
|
print('Received keyboard interrupt. Exiting...')
|
|
exit(1)
|
|
except Exception as e:
|
|
print(f'Error: {e}')
|
|
# create_capture_directory(args.device_name)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|