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 flow_runner():
        print("Flow 1 is running...")
    
    @item
    def flow2_runner():
        print("Flow 2 is running...")
    

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.4.tar.gz (5.0 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.4-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: itemlist-0.1.4.tar.gz
  • Upload date:
  • Size: 5.0 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.4.tar.gz
Algorithm Hash digest
SHA256 f29cecbe64a43d12ffd084c55c58dd35ca74fee424c5c51d2dd3c54bc54a4a8b
MD5 be927cb1b0ef7fc8ea6005e1fd988e1f
BLAKE2b-256 8bb0171207199b27789790cf0782dd3552b752e4305202061501087559cb7cfe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: itemlist-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6a46f6593a7f62342abf09b887d20cf61b0b60af69f75e36c7a72600a7de8ce1
MD5 af6343ce67a528ae78f9bc71a5375cfa
BLAKE2b-256 cb9ea4740844e17da1cc58153637be18a8c6d6c4c5062f31ee18b685373dcf37

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 Pingdom Monitoring Sentry Error logging StatusPage Status page