IngoMeyer441 / simple-term-menu

A Python package which creates simple interactive menus on the command line.
MIT License
492 stars 43 forks source link

Add skip entries option #46

Closed svartkanin closed 2 years ago

svartkanin commented 2 years ago

This addresses #45

I created a new menu option skip_empty_entries that when set will skip over empty entries in the menu.

Skip-able entries can either be defined with empty string or as None. The new option is set to False as default, so if empty or None values or specified it will fail as it does now. But if the option is set to True it will skip the entries when iterating through the menu. This will allow for grouping menu options together visually.

I've tested it with single selection and multiselection.

IngoMeyer441 commented 2 years ago

Thank you very much for contributing! The changes look good to me. I have only some suggestions for minor improvements:

svartkanin commented 2 years ago

Thanks for the quick review and reply. I'm happy to address them, probably towards the end of the weekend :)

svartkanin commented 2 years ago

@IngoMeyer441 I've updated the PR now:

I had issues running the black commit hook. I kept getting the following error

Traceback (most recent call last):
  File ".cache/pre-commit/repootteniip/py_env-python3/bin/black", line 8, in <module>
    sys.exit(patched_main())
  File ".cache/pre-commit/repootteniip/py_env-python3/lib/python3.10/site-packages/black/__init__.py", line 1423, in patched_main
    patch_click()
  File ".cache/pre-commit/repootteniip/py_env-python3/lib/python3.10/site-packages/black/__init__.py", line 1409, in patch_click
    from click import _unicodefun
ImportError: cannot import name '_unicodefun' from 'click' (.cache/pre-commit/repootteniip/py_env-python3/lib/python3.10/site-packages/click/__init__.py)

I updated the hook to the latest version of black and that resolved the issue

IngoMeyer441 commented 2 years ago

Thanks for your changes and your contribution. I tested your code and works fine! I applied some minor improvements to your PR:

I pushed a new commit to the svartkanin-skip-empty-entries branch in this repository. You can apply (and review) the changes with:

git fetch https://github.com/IngoMeyer441/simple-term-menu.git svartkanin-skip-empty-entries
git cherry-pick FETCH_HEAD

If the changes are ok for you, simply push the commit to this PR and I will merge it. Otherwise, please let me know. I am always open for discussion. :slightly_smiling_face:

Thanks again and have a nice weekend! :beers:

svartkanin commented 2 years ago

@IngoMeyer441 thanks for the updates, I've tested things and it seems to work as expected :+1: