24 lines
1.2 KiB
Python
24 lines
1.2 KiB
Python
def setup_argparse():
|
|
# create top level parser
|
|
root_parser = argparse.ArgumentParser(prog='iottb')
|
|
# shared options
|
|
root_parser.add_argument('--verbose', '-v', action='count', default=0)
|
|
root_parser.add_argument('--script-mode', action='store_true', help='Run in script mode (non-interactive)')
|
|
# Group of args w.r.t iottb.db creation
|
|
group = root_parser.add_argument_group('database options')
|
|
group.add_argument('--db-home', default=Path.home() / 'IoTtb.db')
|
|
group.add_argument('--config-home', default=Path.home() / '.config' / 'iottb.conf', type=Path, )
|
|
group.add_argument('--user', default=Path.home().stem, type=Path, )
|
|
|
|
# configure subcommands
|
|
subparsers = root_parser.add_subparsers(title='subcommands', required=True, dest='command')
|
|
# setup_capture_parser(subparsers)
|
|
setup_init_device_root_parser(subparsers)
|
|
setup_sniff_parser(subparsers)
|
|
# Utility to list interfaces directly with iottb instead of relying on external tooling
|
|
|
|
interfaces_parser = subparsers.add_parser('list-interfaces', aliases=['li', 'if'],
|
|
help='List available network interfaces.')
|
|
interfaces_parser.set_defaults(func=list_interfaces)
|
|
|
|
return root_parser |