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

Feature request: select menu for task #1019

Open
charudatta10 opened this issue Jan 17, 2025 · 2 comments
Open

Feature request: select menu for task #1019

charudatta10 opened this issue Jan 17, 2025 · 2 comments

Comments

@charudatta10
Copy link

Discussed in #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

@charudatta10
Copy link
Author

Updated code #1018 (comment)

@charudatta10
Copy link
Author

Updated code #1018 (comment)

Code with TUI selection menu #1018 (reply in thread)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant