Skip to main content

ItemList

ItemList provides a tool for selecting and executing functions in a CLI environment. It offers an intuitive interface for managing and executing multiple workflows or tasks efficiently.

1. Simple Decorator-Based Integration

  • Functions can be added to the menu simply by using the @item decorator. It requires minimal changes to existing functions to integrate them into the CLI menu.

    Example Code:

    @item # only this!
    def func_1():
        print("func_1 is executing...")
    
    @item
    def func_2(description="Perform another important task"):
        print("func_2 is executing...")
    

itemlist

2. Intuitive CLI Interface

  • Utilizing the curses library, users can navigate through options smoothly with arrow keys or j/k. The currently selected item is displayed in bold for better visibility.

3. Efficient Search Functionality

  • The menu includes a search bar, allowing users to filter options by function name or description. This makes it easy to quickly find the desired function, even among numerous options.

4. Function Registration with Descriptions

  • Each function can be registered with an optional description. This allows users to easily understand the purpose or details of each task, reducing the chance of incorrect selections.

Installation

pip install itemlist

Usage

More details can be found in the examples directory.

from itemlist import item

@item
def flow_runner(description="Run the first flow"):
    run_locally(flow)

@item
def flow2_runner(description="Run the second flow"):
    run_locally(flow2)

@item
def flow3_runner(description="Run the third flow"):
    run_locally(flow3)

if __name__ == '__main__':
    selected = item.select()
    item.endwin()

    selected_name, selected_func, selected_func_description = selected

    if selected_func == item._cancel:
        print("Cancel selected. Exiting the program.")
    else:
        print(f"Running: {selected_name}\n")
        print(f"Description: {selected_func_description}\n")
        selected_func()

License

MIT License

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

itemlist-0.1.3.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

itemlist-0.1.3-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file itemlist-0.1.3.tar.gz.

File metadata

  • Download URL: itemlist-0.1.3.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for itemlist-0.1.3.tar.gz
Algorithm Hash digest
SHA256 638cc861f1953096f646fdd222f6bc02704487271d39fe6e3476c84c1411962e
MD5 b863de915c4e47d4de05b384c385a51b
BLAKE2b-256 3c820ec978b60a4c8b7af0897cb39a34b7a825e98ae3d8e9399787b9521ac4f9

See more details on using hashes here.

File details

Details for the file itemlist-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: itemlist-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for itemlist-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1cd59dfdf4416a7a37cc37de3d7e626ff2fc88f706b9d61f5b01617daaa77810
MD5 7179c9042be1f8e64d6f18c2b7f58b1a
BLAKE2b-256 4667bc05c03970d3ee0648adcffdbbdcb53c8b8933639b20a04f8d97d2f6ba57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page