sp-hydra-veil-cli/cli/commands/get_set.py
2026-05-30 08:25:00 -05:00

40 lines
No EOL
1.7 KiB
Python

from core.controllers.ConfigurationController import ConfigurationController
NAME = 'get'
NAME_SET = 'set'
def register(subparsers):
get_parser = subparsers.add_parser(NAME)
get_subs = get_parser.add_subparsers(title='subcommands', dest='subcommand')
get_subs.add_parser('connection')
get_subs.add_parser('endpoint_verification')
set_parser = subparsers.add_parser(NAME_SET)
set_subs = set_parser.add_subparsers(title='subcommands', dest='subcommand')
set_connection = set_subs.add_parser('connection')
set_connection.add_argument('connection_type', choices=['system', 'tor'])
set_endpoint = set_subs.add_parser('endpoint_verification')
set_endpoint.add_argument('endpoint_verification_state', choices=['enabled', 'disabled'])
return get_parser
def handle(arguments, main_parser):
if arguments.command == NAME:
if arguments.subcommand is None:
main_parser.parse_args(['get', '--help'])
elif arguments.subcommand == 'connection':
print(ConfigurationController.get_connection())
elif arguments.subcommand == 'endpoint_verification':
print('enabled' if ConfigurationController.get_endpoint_verification_enabled() else 'disabled')
elif arguments.command == NAME_SET:
if arguments.subcommand is None:
main_parser.parse_args(['set', '--help'])
elif arguments.subcommand == 'connection':
ConfigurationController.set_connection(arguments.connection_type)
elif arguments.subcommand == 'endpoint_verification':
ConfigurationController.set_endpoint_verification_enabled(arguments.endpoint_verification_state == 'enabled')