Add click.echo to CLI commands for improved user feedback
This commit is contained in:
86
core/cli.py
86
core/cli.py
@ -5,7 +5,6 @@ import click
|
|||||||
import cli_api
|
import cli_api
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
def pretty_print(data: typing.Any):
|
def pretty_print(data: typing.Any):
|
||||||
if isinstance(data, dict):
|
if isinstance(data, dict):
|
||||||
print(json.dumps(data, indent=4))
|
print(json.dumps(data, indent=4))
|
||||||
@ -13,70 +12,69 @@ def pretty_print(data: typing.Any):
|
|||||||
|
|
||||||
print(data)
|
print(data)
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
def cli():
|
def cli():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# region Hysteria2
|
# region Hysteria2
|
||||||
|
|
||||||
|
|
||||||
@cli.command('install-hysteria2')
|
@cli.command('install-hysteria2')
|
||||||
@click.option('--port', '-p', required=True, help='Port for Hysteria2', type=int)
|
@click.option('--port', '-p', required=True, help='Port for Hysteria2', type=int)
|
||||||
@click.option('--sni', '-s', required=False, default='bts.com', help='SNI for Hysteria2 (default: bts.com)', type=str)
|
@click.option('--sni', '-s', required=False, default='bts.com', help='SNI for Hysteria2 (default: bts.com)', type=str)
|
||||||
def install_hysteria2(port: int, sni: str):
|
def install_hysteria2(port: int, sni: str):
|
||||||
try:
|
try:
|
||||||
cli_api.install_hysteria2(port, sni)
|
cli_api.install_hysteria2(port, sni)
|
||||||
|
click.echo(f"Hysteria2 installed successfully on port {port} with SNI {sni}.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('uninstall-hysteria2')
|
@cli.command('uninstall-hysteria2')
|
||||||
def uninstall_hysteria2():
|
def uninstall_hysteria2():
|
||||||
try:
|
try:
|
||||||
cli_api.uninstall_hysteria2()
|
cli_api.uninstall_hysteria2()
|
||||||
|
click.echo("Hysteria2 uninstalled successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('update-hysteria2')
|
@cli.command('update-hysteria2')
|
||||||
def update_hysteria2():
|
def update_hysteria2():
|
||||||
try:
|
try:
|
||||||
cli_api.update_hysteria2()
|
cli_api.update_hysteria2()
|
||||||
|
click.echo("Hysteria2 updated successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('restart-hysteria2')
|
@cli.command('restart-hysteria2')
|
||||||
def restart_hysteria2():
|
def restart_hysteria2():
|
||||||
try:
|
try:
|
||||||
cli_api.restart_hysteria2()
|
cli_api.restart_hysteria2()
|
||||||
|
click.echo("Hysteria2 restarted successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('change-hysteria2-port')
|
@cli.command('change-hysteria2-port')
|
||||||
@click.option('--port', '-p', required=True, help='New port for Hysteria2', type=int)
|
@click.option('--port', '-p', required=True, help='New port for Hysteria2', type=int)
|
||||||
def change_hysteria2_port(port: int):
|
def change_hysteria2_port(port: int):
|
||||||
try:
|
try:
|
||||||
cli_api.change_hysteria2_port(port)
|
cli_api.change_hysteria2_port(port)
|
||||||
|
click.echo(f"Hysteria2 port changed to {port} successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('change-hysteria2-sni')
|
@cli.command('change-hysteria2-sni')
|
||||||
@click.option('--sni', '-s', required=True, help='New SNI for Hysteria2', type=str)
|
@click.option('--sni', '-s', required=True, help='New SNI for Hysteria2', type=str)
|
||||||
def change_hysteria2_sni(sni: str):
|
def change_hysteria2_sni(sni: str):
|
||||||
try:
|
try:
|
||||||
cli_api.change_hysteria2_sni(sni)
|
cli_api.change_hysteria2_sni(sni)
|
||||||
|
click.echo(f"Hysteria2 SNI changed to {sni} successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('backup-hysteria')
|
@cli.command('backup-hysteria')
|
||||||
def backup_hysteria():
|
def backup_hysteria():
|
||||||
try:
|
try:
|
||||||
cli_api.backup_hysteria()
|
cli_api.backup_hysteria()
|
||||||
|
click.echo("Hysteria configuration backed up successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
@ -84,12 +82,14 @@ def backup_hysteria():
|
|||||||
|
|
||||||
# region User
|
# region User
|
||||||
|
|
||||||
|
|
||||||
@ cli.command('list-users')
|
@ cli.command('list-users')
|
||||||
def list_users():
|
def list_users():
|
||||||
try:
|
try:
|
||||||
if res := cli_api.list_users():
|
res = cli_api.list_users()
|
||||||
|
if res:
|
||||||
pretty_print(res)
|
pretty_print(res)
|
||||||
|
else:
|
||||||
|
click.echo("No users found.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
@ -109,14 +109,14 @@ def get_user(username: str):
|
|||||||
@click.option('--traffic-limit', '-t', required=True, help='Traffic limit for the new user in GB', type=int)
|
@click.option('--traffic-limit', '-t', required=True, help='Traffic limit for the new user in GB', type=int)
|
||||||
@click.option('--expiration-days', '-e', required=True, help='Expiration days for the new user', type=int)
|
@click.option('--expiration-days', '-e', required=True, help='Expiration days for the new user', type=int)
|
||||||
@click.option('--password', '-p', required=False, help='Password for the user', type=str)
|
@click.option('--password', '-p', required=False, help='Password for the user', type=str)
|
||||||
@click.option('--creation-date', '-c', required=False, help='Creation date for the user', type=str)
|
@click.option('--creation-date', '-c', required=False, help='Creation date for the user (YYYY-MM-DD)', type=str)
|
||||||
def add_user(username: str, traffic_limit: int, expiration_days: int, password: str, creation_date: str):
|
def add_user(username: str, traffic_limit: int, expiration_days: int, password: str, creation_date: str):
|
||||||
try:
|
try:
|
||||||
cli_api.add_user(username, traffic_limit, expiration_days, password, creation_date)
|
cli_api.add_user(username, traffic_limit, expiration_days, password, creation_date)
|
||||||
|
click.echo(f"User '{username}' added successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('edit-user')
|
@cli.command('edit-user')
|
||||||
@click.option('--username', '-u', required=True, help='Username for the user to edit', type=str)
|
@click.option('--username', '-u', required=True, help='Username for the user to edit', type=str)
|
||||||
@click.option('--new-username', '-nu', required=False, help='New username for the user', type=str)
|
@click.option('--new-username', '-nu', required=False, help='New username for the user', type=str)
|
||||||
@ -129,28 +129,28 @@ def edit_user(username: str, new_username: str, new_traffic_limit: int, new_expi
|
|||||||
try:
|
try:
|
||||||
cli_api.edit_user(username, new_username, new_traffic_limit, new_expiration_days,
|
cli_api.edit_user(username, new_username, new_traffic_limit, new_expiration_days,
|
||||||
renew_password, renew_creation_date, blocked)
|
renew_password, renew_creation_date, blocked)
|
||||||
|
click.echo(f"User '{username}' updated successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@ cli.command('reset-user')
|
@ cli.command('reset-user')
|
||||||
@ click.option('--username', '-u', required=True, help='Username for the user to Reset', type=str)
|
@ click.option('--username', '-u', required=True, help='Username for the user to Reset', type=str)
|
||||||
def reset_user(username: str):
|
def reset_user(username: str):
|
||||||
try:
|
try:
|
||||||
cli_api.reset_user(username)
|
cli_api.reset_user(username)
|
||||||
|
click.echo(f"User '{username}' reset successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@ cli.command('remove-user')
|
@ cli.command('remove-user')
|
||||||
@ click.option('--username', '-u', required=True, help='Username for the user to remove', type=str)
|
@ click.option('--username', '-u', required=True, help='Username for the user to remove', type=str)
|
||||||
def remove_user(username: str):
|
def remove_user(username: str):
|
||||||
try:
|
try:
|
||||||
cli_api.remove_user(username)
|
cli_api.remove_user(username)
|
||||||
|
click.echo(f"User '{username}' removed successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('show-user-uri')
|
@cli.command('show-user-uri')
|
||||||
@click.option('--username', '-u', required=True, help='Username for the user to show the URI', type=str)
|
@click.option('--username', '-u', required=True, help='Username for the user to show the URI', type=str)
|
||||||
@click.option('--qrcode', '-qr', is_flag=True, help='Generate QR code for the URI')
|
@click.option('--qrcode', '-qr', is_flag=True, help='Generate QR code for the URI')
|
||||||
@ -160,18 +160,22 @@ def remove_user(username: str):
|
|||||||
@click.option('--normalsub', '-n', is_flag=True, help='Generate Normal sublink if normalsub service is active')
|
@click.option('--normalsub', '-n', is_flag=True, help='Generate Normal sublink if normalsub service is active')
|
||||||
def show_user_uri(username: str, qrcode: bool, ipv: int, all: bool, singbox: bool, normalsub: bool):
|
def show_user_uri(username: str, qrcode: bool, ipv: int, all: bool, singbox: bool, normalsub: bool):
|
||||||
try:
|
try:
|
||||||
cli_api.show_user_uri(username, qrcode, ipv, all, singbox, normalsub)
|
res = cli_api.show_user_uri(username, qrcode, ipv, all, singbox, normalsub)
|
||||||
|
if res:
|
||||||
|
click.echo(res)
|
||||||
|
else:
|
||||||
|
click.echo(f"URI for user '{username}' could not be generated.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
# region Server
|
# region Server
|
||||||
@ cli.command('traffic-status')
|
@ cli.command('traffic-status')
|
||||||
def traffic_status():
|
def traffic_status():
|
||||||
cli_api.traffic_status()
|
try:
|
||||||
# traffic.traffic_status()
|
cli_api.traffic_status()
|
||||||
|
except Exception as e:
|
||||||
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
@cli.command('server-info')
|
@cli.command('server-info')
|
||||||
def server_info():
|
def server_info():
|
||||||
@ -179,20 +183,21 @@ def server_info():
|
|||||||
res = cli_api.server_info()
|
res = cli_api.server_info()
|
||||||
if res:
|
if res:
|
||||||
pretty_print(res)
|
pretty_print(res)
|
||||||
|
else:
|
||||||
|
click.echo("Server information not available.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('manage_obfs')
|
@cli.command('manage_obfs')
|
||||||
@click.option('--remove', '-r', is_flag=True, help="Remove 'obfs' from config.json.")
|
@click.option('--remove', '-r', is_flag=True, help="Remove 'obfs' from config.json.")
|
||||||
@click.option('--generate', '-g', is_flag=True, help="Generate new 'obfs' in config.json.")
|
@click.option('--generate', '-g', is_flag=True, help="Generate new 'obfs' in config.json.")
|
||||||
def manage_obfs(remove: bool, generate: bool):
|
def manage_obfs(remove: bool, generate: bool):
|
||||||
try:
|
try:
|
||||||
cli_api.manage_obfs(remove, generate)
|
cli_api.manage_obfs(remove, generate)
|
||||||
|
click.echo("Obfs configuration updated successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('ip-address')
|
@cli.command('ip-address')
|
||||||
@click.option('--edit', is_flag=True, help="Edit IP addresses manually.")
|
@click.option('--edit', is_flag=True, help="Edit IP addresses manually.")
|
||||||
@click.option('-4', '--ipv4', type=str, help="Specify the new IPv4 address.")
|
@click.option('-4', '--ipv4', type=str, help="Specify the new IPv4 address.")
|
||||||
@ -205,10 +210,10 @@ def ip_address(edit: bool, ipv4: str, ipv6: str):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
cli_api.ip_address(edit, ipv4, ipv6)
|
cli_api.ip_address(edit, ipv4, ipv6)
|
||||||
|
click.echo("IP address configuration updated successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('update-geo')
|
@cli.command('update-geo')
|
||||||
@click.option('--country', '-c',
|
@click.option('--country', '-c',
|
||||||
type=click.Choice(['iran', 'china', 'russia'], case_sensitive=False),
|
type=click.Choice(['iran', 'china', 'russia'], case_sensitive=False),
|
||||||
@ -217,10 +222,10 @@ def ip_address(edit: bool, ipv4: str, ipv6: str):
|
|||||||
def update_geo(country: str):
|
def update_geo(country: str):
|
||||||
try:
|
try:
|
||||||
cli_api.update_geo(country)
|
cli_api.update_geo(country)
|
||||||
|
click.echo(f"Geo files for {country} updated successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('masquerade')
|
@cli.command('masquerade')
|
||||||
@click.option('--remove', '-r', is_flag=True, help="Remove 'masquerade' from config.json.")
|
@click.option('--remove', '-r', is_flag=True, help="Remove 'masquerade' from config.json.")
|
||||||
@click.option('--enable', '-e', metavar="<domain>", type=str, help="Enable 'masquerade' in config.json with the specified domain.")
|
@click.option('--enable', '-e', metavar="<domain>", type=str, help="Enable 'masquerade' in config.json with the specified domain.")
|
||||||
@ -228,6 +233,7 @@ def masquerade(remove: bool, enable: str):
|
|||||||
"""Manage 'masquerade' in Hysteria2 configuration."""
|
"""Manage 'masquerade' in Hysteria2 configuration."""
|
||||||
try:
|
try:
|
||||||
cli_api.masquerade(remove, enable)
|
cli_api.masquerade(remove, enable)
|
||||||
|
click.echo("Masquerade configuration updated successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
@ -235,31 +241,30 @@ def masquerade(remove: bool, enable: str):
|
|||||||
|
|
||||||
# region Advanced Menu
|
# region Advanced Menu
|
||||||
|
|
||||||
|
|
||||||
@ cli.command('install-tcp-brutal')
|
@ cli.command('install-tcp-brutal')
|
||||||
def install_tcp_brutal():
|
def install_tcp_brutal():
|
||||||
try:
|
try:
|
||||||
cli_api.install_tcp_brutal()
|
cli_api.install_tcp_brutal()
|
||||||
|
click.echo("TCP Brutal installed successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@ cli.command('install-warp')
|
@ cli.command('install-warp')
|
||||||
def install_warp():
|
def install_warp():
|
||||||
try:
|
try:
|
||||||
cli_api.install_warp()
|
cli_api.install_warp()
|
||||||
|
click.echo("WARP installed successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@ cli.command('uninstall-warp')
|
@ cli.command('uninstall-warp')
|
||||||
def uninstall_warp():
|
def uninstall_warp():
|
||||||
try:
|
try:
|
||||||
cli_api.uninstall_warp()
|
cli_api.uninstall_warp()
|
||||||
|
click.echo("WARP uninstalled successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('configure-warp')
|
@cli.command('configure-warp')
|
||||||
@click.option('--all', '-a', is_flag=True, help='Use WARP for all connections')
|
@click.option('--all', '-a', is_flag=True, help='Use WARP for all connections')
|
||||||
@click.option('--popular-sites', '-p', is_flag=True, help='Use WARP for popular sites like Google, OpenAI, etc')
|
@click.option('--popular-sites', '-p', is_flag=True, help='Use WARP for popular sites like Google, OpenAI, etc')
|
||||||
@ -270,60 +275,55 @@ def uninstall_warp():
|
|||||||
def configure_warp(all: bool, popular_sites: bool, domestic_sites: bool, block_adult_sites: bool, warp_option: str, warp_key: str):
|
def configure_warp(all: bool, popular_sites: bool, domestic_sites: bool, block_adult_sites: bool, warp_option: str, warp_key: str):
|
||||||
try:
|
try:
|
||||||
cli_api.configure_warp(all, popular_sites, domestic_sites, block_adult_sites, warp_option, warp_key)
|
cli_api.configure_warp(all, popular_sites, domestic_sites, block_adult_sites, warp_option, warp_key)
|
||||||
|
click.echo("WARP configured successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('warp-status')
|
@cli.command('warp-status')
|
||||||
def warp_status():
|
def warp_status():
|
||||||
try:
|
try:
|
||||||
res = cli_api.warp_status()
|
res = cli_api.warp_status()
|
||||||
if res:
|
if res:
|
||||||
pretty_print(res)
|
pretty_print(res)
|
||||||
|
else:
|
||||||
|
click.echo("WARP status not available.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('telegram')
|
@cli.command('telegram')
|
||||||
@click.option('--action', '-a', required=True, help='Action to perform: start or stop', type=click.Choice(['start', 'stop'], case_sensitive=False))
|
@click.option('--action', '-a', required=True, help='Action to perform: start or stop', type=click.Choice(['start', 'stop'], case_sensitive=False))
|
||||||
@click.option('--token', '-t', required=False, help='Token for running the telegram bot', type=str)
|
@click.option('--token', '-t', required=False, help='Token for running the telegram bot', type=str)
|
||||||
@click.option('--adminid', '-aid', required=False, help='Telegram admins ID for running the telegram bot', type=str)
|
@click.option('--adminid', '-aid', required=False, help='Telegram admins ID for running the telegram bot', type=str)
|
||||||
def telegram(action: str, token: str, adminid: str):
|
def telegram(action: str, token: str, adminid: str):
|
||||||
try:
|
try:
|
||||||
res = cli_api.telegram(action, token, adminid)
|
cli_api.telegram(action, token, adminid)
|
||||||
if res:
|
click.echo(f"Telegram bot {action}ed successfully.")
|
||||||
pretty_print(res)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('singbox')
|
@cli.command('singbox')
|
||||||
@click.option('--action', '-a', required=True, help='Action to perform: start or stop', type=click.Choice(['start', 'stop'], case_sensitive=False))
|
@click.option('--action', '-a', required=True, help='Action to perform: start or stop', type=click.Choice(['start', 'stop'], case_sensitive=False))
|
||||||
@click.option('--domain', '-d', required=False, help='Domain name for SSL', type=str)
|
@click.option('--domain', '-d', required=False, help='Domain name for SSL', type=str)
|
||||||
@click.option('--port', '-p', required=False, help='Port number for Singbox service', type=int)
|
@click.option('--port', '-p', required=False, help='Port number for Singbox service', type=int)
|
||||||
def singbox(action: str, domain: str, port: int):
|
def singbox(action: str, domain: str, port: int):
|
||||||
try:
|
try:
|
||||||
res = cli_api.singbox(action, domain, port)
|
cli_api.singbox(action, domain, port)
|
||||||
if res:
|
click.echo(f"Singbox service {action}ed successfully.")
|
||||||
pretty_print(res)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
|
|
||||||
@cli.command('normal-sub')
|
@cli.command('normal-sub')
|
||||||
@click.option('--action', '-a', required=True, help='Action to perform: start or stop', type=click.Choice(['start', 'stop'], case_sensitive=False))
|
@click.option('--action', '-a', required=True, help='Action to perform: start or stop', type=click.Choice(['start', 'stop'], case_sensitive=False))
|
||||||
@click.option('--domain', '-d', required=False, help='Domain name for SSL', type=str)
|
@click.option('--domain', '-d', required=False, help='Domain name for SSL', type=str)
|
||||||
@click.option('--port', '-p', required=False, help='Port number for NormalSub service', type=int)
|
@click.option('--port', '-p', required=False, help='Port number for NormalSub service', type=int)
|
||||||
def normalsub(action: str, domain: str, port: int):
|
def normalsub(action: str, domain: str, port: int):
|
||||||
try:
|
try:
|
||||||
res = cli_api.normalsub(action, domain, port)
|
cli_api.normalsub(action, domain, port)
|
||||||
if res:
|
click.echo(f"NormalSub service {action}ed successfully.")
|
||||||
pretty_print(res)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
click.echo(f'{e}', err=True)
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
cli()
|
cli()
|
||||||
|
|||||||
Reference in New Issue
Block a user