Feature request: select menu for task

Open
#1,019 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
cli

Research direction

Start by reviewing the existing invoke --list CLI output and the linked discussion #1018. Clarify the native task-selection interaction and its scope, then identify the CLI entry point that owns task listing. Done means users can select a task through Invoke itself rather than an ad-hoc wrapper, with the behavior agreed in the discussion.

Written by the indexing model from the issue text.

Description

Discussed in https://github.com/pyinvoke/invoke/discussions/1018

Originally posted by charudatta10 January 16, 2025
A terminal user interface to select task similar to one implemented in just using just --choose command. I had implemented ad-hoc solution as follow:

@task
def default(c):
    # Run `invoke --list` to get a list of tasks
    result = subprocess.run(['invoke', '--list'], capture_output=True, text=True)
    tasks_output = result.stdout

    # Parse the tasks from the output
    tasks = []
    for line in tasks_output.split('\n'):
        if line.strip() and not line.strip().startswith('Available tasks'):
            task_name = line.strip().split(' ')[0]
            tasks.append(task_name)

    # Display tasks to the user
    print("Choose a task:")
    for i, task_name in enumerate(tasks, 1):
        print(f"{i}: {task_name}")

    # User selects a task
    choice = int(input("Enter the number of your choice: "))
    task_name = tasks[choice - 1]
    c.run(f"invoke {task_name}")

looking for native solution

Dominant language
Python
Stars
4.8k
Forks
412
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pyinvoke/invoke

All issues in pyinvoke/invoke

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.