-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
48 lines (39 loc) · 1.37 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from invoke import task, Collection, Context
import os
@task
def commit(ctx, message="init"):
ctx.run("git add .")
ctx.run(f"git commit -m \"{message}\"")
@task
def quit(ctx):
print("Copyright © 2024 Charudatta")
@task
def test(ctx):
ctx.run("python -m unittest discover -s tests")
@task
def run(ctx):
choice = input("Enter the input argument add/ remove: ")
print("Current directory files:")
# Get the list of files in the current directory
files = [f for f in os.listdir() if os.path.isfile(f)]
# Display the list of files with indices
print("Select a file from the list:")
for i, file in enumerate(files):
print(f"{i}: {file}")
# Get the file index from the user
file_index = int(input("Enter the file number: "))
# Get the selected file name
filename = files[file_index]
tags = input("Enter the tags (separated by spaces): ").split()
ctx.run(f"python __main__.py {choice} {filename} {' '.join(tags)}")
@task(default=True)
def default(ctx):
# Get a list of tasks
tasks = sorted(ns.tasks.keys())
# Display tasks and prompt user
for i, task_name in enumerate(tasks, 1):
print(f"{i}: {task_name}")
choice = int(input("Enter the number of your choice: "))
ctx.run(f"invoke {tasks[choice - 1]}")
# Create a collection of tasks
ns = Collection(commit, quit, test, run, default)