cyberpanel icon indicating copy to clipboard operation
cyberpanel copied to clipboard

Improve CyberPanel CLI Usability and Version Handling

Open dxniel7402 opened this issue 1 year ago • 2 comments

While orchestrating CyberPanel with Ansible, I decided to leverage the cyberpanel-cli. While I have the programming knowledge to understand the functionalities of the cli and how to invoke them, the user-friendliness of the CLI was lacking in certain areas (for example, no info was provided about which functions the user could call). The code changes in this pull request have therefore focused on improving user-friendliness in the following areas:

  1. Added a new method getAllowedFunctions() to the cliParser class that maintains a static list of available functions. These functions are grouped into categories such as "Website Management", "DNS Management", "Backup Management" and more. This list is used to validate the function argument provided by the user and to print the list of available functions if an unknown function is provided. Improved the error handling when an unknown function is provided as argument to the cli. Now it not only prints the help message from ArgumentParser, but also indicates that the function is unknown and prints a neatly formatted list of available functions.

  2. Additionally, I've corrected the version output, as it was not working correctly: I've updated the get_cyberpanel_version function to handle non-JSON data. Previously, it could only interpret JSON formatted data from version.txt and would fail if the data was provided as plain text lines (which is the case after a new installation). The function now attempts to interpret the data as JSON first and if that fails, it tries to interpret the data as plain text lines. This allows for greater flexibility in the format of the data in version.txt, making the function more robust to changes in the way version information is stored.

The proposed changes aim to make the CyberPanel CLI more user-friendly, especially for users who aren't familiar with the underlying code or Python programming. I hope these changes are helpful and I welcome any feedback.

dxniel7402 avatar May 18 '23 15:05 dxniel7402

Oh by the way: Tested and verified on an AlmaLinux 8.4 server. Both, server and CyberPanel were freshly installed.After installation, only the two files were updated.

dxniel7402 avatar May 18 '23 22:05 dxniel7402

Not connected with the development of CyberPanel, though the commit looks simple and concise to me.

Lvl4Sword avatar May 24 '23 11:05 Lvl4Sword