feat: Add CLI command to edit NormalSub subpath

- Added `edit_normalsub_subpath` function to `cli_api.py` to
  interact with the `normalsub.sh edit_subpath` command, including
  input validation for the new subpath.
- Updated the `normal-sub` command in `cli.py`:
  - Added 'edit_subpath' as a valid action.
  - Introduced a '--subpath' option for specifying the new path.
  - Modified the command logic to call the new API function when
    the 'edit_subpath' action is selected.
This commit is contained in:
Whispering Wind
2025-05-17 23:24:43 +03:30
committed by GitHub
parent 6c5486eafc
commit edcc4e32e2
2 changed files with 20 additions and 4 deletions

View File

@ -510,6 +510,14 @@ def start_normalsub(domain: str, port: int):
raise InvalidInputError('Error: Both --domain and --port are required for the start action.')
run_cmd(['bash', Command.INSTALL_NORMALSUB.value, 'start', domain, str(port)])
def edit_normalsub_subpath(new_subpath: str):
'''Edits the subpath for NormalSub service.'''
if not new_subpath:
raise InvalidInputError('Error: New subpath cannot be empty.')
if not new_subpath.isalnum():
raise InvalidInputError('Error: New subpath must contain only alphanumeric characters (a-z, A-Z, 0-9).')
run_cmd(['bash', Command.INSTALL_NORMALSUB.value, 'edit_subpath', new_subpath])
def stop_normalsub():
'''Stops NormalSub.'''