Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move TUI user input options to a class #297

Merged
merged 3 commits into from
Nov 18, 2024

Conversation

NTFSvolume
Copy link
Collaborator

  1. Redefine all TUI prompts into 3 levels:

    • basic_prompt.py for standard prompts like ask_file_path, enter_to_continue or ask_text
    • user_prompts.py for CDL specific prompts like import v4 config or extract cookies from browser. These prompts could have nested prompts
    • program_ui.py with the class ProgramUI which contains all the custom user prompts of the program as methods
  2. All prompts are now dynamically created passing a dict with the menu options and a mapping with the function that each option will execute

  3. Remove all prompts that were unnecessary cause they were asking the same values as the config files. Edit URLs.txt, Edit current config, Edit authentication config and Edit global config are still present in the UI but now they just open the respective file in notepad or the default text editor of the OS

  4. Switch back to using os.system('cls') to clear the screen on Windows. rich.console.clear() uses ANSI escape codes to clear the terminal and the legacy cmd does not support them. This let to prompts being rendered over leftover characters in the buffer.

  5. Browser_Cookies options browsers and sites are now defined as lists in the config definition

  6. Add all and default as hardcoded internal configs names. The user cannot create configs with those names. The idea with reserving all is for the user to pass it as a CLI argument to indicate that they want to run all configs sequentially. This will help to collapse some CLI arguments which are essentially duplicated cause they have a single config version and an all config version. None of the logic for this is implemented in this PR, they were just added as a reserved name

1. Redefine all TUI prompts into 3 levels:

    - `basic_prompt.py` for standard prompts like `ask_file_path`, `enter_to_continue` or `ask_text`
    - `user_prompts.py` for CDL specific prompts like `import v4 config` or `extract cookies from browser`. These prompts could have nested prompts
    - `program_ui.py` with the class `ProgramUI` which contains all the custom user prompts of the program as methods
2. All prompts are now dynamically created passing a dict with the menu options and a mapping with the function that each option will execute
3. Remove all prompts that were unnecessary cause they were asking the same values as the config files. `Edit URLs.txt`, `Edit current config`, `Edit authentication config` and `Edit global config` are still present in the UI but now they just open the respective file in notepad or the default text editor of the OS
4. Switch back to using `os.system('cls')` to clear the screen on Windows. `rich.console.clear()` uses ANSI escape codes to clear the terminal and the legacy `cmd` does not support them. This let to prompts being rendered over leftover characters in the buffer.
5. `Browser_Cookies` options `browsers` and `sites` are now defined as lists in the config definition
6. Add `all` and `default` as hardcoded internal configs names. The user cannot create configs with those names. The idea with reserving `all` is for the user to pass it as a CLI argument to indicate that they want to run all configs sequentially. This will help to collapse some CLI arguments which are essentially duplicated cause they have a `single config` version and an `all config` version. None of the logic for this is implemented in this PR, they were just added as a reserved name
@NTFSvolume NTFSvolume added the refactor No user facing changes label Nov 17, 2024
@NTFSvolume NTFSvolume requested a review from jbsparrow November 17, 2024 13:22
cyberdrop_dl/ui/prompts/user_prompts.py Outdated Show resolved Hide resolved
cyberdrop_dl/ui/prompts/user_prompts.py Outdated Show resolved Hide resolved
@jbsparrow jbsparrow merged commit b512732 into jbsparrow:master Nov 18, 2024
2 of 3 checks passed
@NTFSvolume NTFSvolume deleted the updated_ui branch November 18, 2024 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor No user facing changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants