-
Notifications
You must be signed in to change notification settings - Fork 0
feat: TUI state persistence, new commands, and non-interactive improvements #11
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
Changes from all commits
56b4ce5
29d6de6
ad09caa
0e48fcf
9066d76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| __version__ = "0.10.16" | ||
| __version__ = "0.10.17" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| """Add-link command for adding URLs to task links.""" | ||
|
|
||
| from typing import Optional | ||
|
|
||
| import click | ||
|
|
||
| from taskrepo.core.repository import RepositoryManager | ||
| from taskrepo.utils.helpers import find_task_by_title_or_id, select_task_from_result | ||
|
|
||
|
|
||
| @click.command(name="add-link") | ||
| @click.argument("task_id", required=True) | ||
| @click.argument("url", required=True) | ||
| @click.option("--repo", "-r", help="Repository name (will search all repos if not specified)") | ||
| @click.pass_context | ||
| def add_link(ctx, task_id: str, url: str, repo: Optional[str]): | ||
| """Add a link/URL to a task. | ||
| Examples: | ||
| tsk add-link 5 "https://github.com/org/repo/issues/123" | ||
| tsk add-link 10 "https://mail.google.com/..." --repo work | ||
| TASK_ID: Task ID, UUID, or title | ||
| URL: URL to add to task links | ||
| """ | ||
| config = ctx.obj["config"] | ||
| manager = RepositoryManager(config.parent_dir) | ||
|
|
||
| # Validate URL format | ||
| if not url.startswith(("http://", "https://")): | ||
| click.secho("Error: URL must start with http:// or https://", fg="red", err=True) | ||
| ctx.exit(1) | ||
|
|
||
| # Find task | ||
| result = find_task_by_title_or_id(manager, task_id, repo) | ||
|
|
||
| if result[0] is None: | ||
| click.secho(f"Error: No task found matching '{task_id}'", fg="red", err=True) | ||
| ctx.exit(1) | ||
|
|
||
| task, repository = select_task_from_result(ctx, result, task_id) | ||
|
|
||
| # Add link if not already present | ||
| if task.links is None: | ||
| task.links = [] | ||
|
|
||
| if url in task.links: | ||
| click.secho(f"Link already exists in task: {task.title}", fg="yellow") | ||
| ctx.exit(0) | ||
|
|
||
| task.links.append(url) | ||
|
|
||
| # Save task | ||
| repository.save_task(task) | ||
|
|
||
| click.secho(f"β Added link to task: {task.title}", fg="green") | ||
| click.echo(f"\nLink added: {url}") | ||
| click.echo(f"Total links: {len(task.links)}") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| """Append command for adding content to task descriptions.""" | ||
|
|
||
| from typing import Optional | ||
|
||
|
|
||
| import click | ||
|
|
||
| from taskrepo.core.repository import RepositoryManager | ||
| from taskrepo.utils.helpers import find_task_by_title_or_id, select_task_from_result | ||
|
|
||
|
|
||
| @click.command() | ||
| @click.argument("task_id", required=True) | ||
| @click.option("--text", "-t", required=True, help="Text to append to task description") | ||
| @click.option("--repo", "-r", help="Repository name (will search all repos if not specified)") | ||
| @click.pass_context | ||
| def append(ctx, task_id: str, text: str, repo: Optional[str]): | ||
| """Append text to a task's description. | ||
| Examples: | ||
| tsk append 5 --text "Additional note from meeting" | ||
| tsk append 10 -t "Updated requirements" --repo work | ||
| TASK_ID: Task ID, UUID, or title to append to | ||
| """ | ||
| config = ctx.obj["config"] | ||
| manager = RepositoryManager(config.parent_dir) | ||
|
|
||
| # Find task | ||
| result = find_task_by_title_or_id(manager, task_id, repo) | ||
|
|
||
| if result[0] is None: | ||
| click.secho(f"Error: No task found matching '{task_id}'", fg="red", err=True) | ||
| ctx.exit(1) | ||
|
|
||
| task, repository = select_task_from_result(ctx, result, task_id) | ||
|
|
||
| # Append text to description | ||
| if task.description: | ||
| task.description = task.description.rstrip() + "\n\n" + text | ||
| else: | ||
| task.description = text | ||
|
|
||
| # Save task | ||
| repository.save_task(task) | ||
|
|
||
| click.secho(f"β Appended text to task: {task.title}", fg="green") | ||
| click.echo("\nNew content added:") | ||
| click.echo(f" {text}") | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,15 +18,54 @@ | |||||||||||||||||||||||||||||||||||||||
| @click.argument("task_ids", nargs=-1) | ||||||||||||||||||||||||||||||||||||||||
| @click.option("--repo", "-r", help="Repository name (will search all repos if not specified)") | ||||||||||||||||||||||||||||||||||||||||
| @click.option("--yes", "-y", is_flag=True, help="Automatically archive subtasks (skip prompt)") | ||||||||||||||||||||||||||||||||||||||||
| @click.option("--all-completed", is_flag=True, help="Archive all completed tasks") | ||||||||||||||||||||||||||||||||||||||||
| @click.pass_context | ||||||||||||||||||||||||||||||||||||||||
| def archive(ctx, task_ids: Tuple[str, ...], repo, yes): | ||||||||||||||||||||||||||||||||||||||||
| def archive(ctx, task_ids: Tuple[str, ...], repo, yes, all_completed): | ||||||||||||||||||||||||||||||||||||||||
| """Archive one or more tasks, or list archived tasks if no task IDs are provided. | ||||||||||||||||||||||||||||||||||||||||
| TASK_IDS: One or more task IDs to archive (optional - if omitted, lists archived tasks) | ||||||||||||||||||||||||||||||||||||||||
| Use --all-completed to archive all tasks with status 'completed' in one command. | ||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||
| config = ctx.obj["config"] | ||||||||||||||||||||||||||||||||||||||||
| manager = RepositoryManager(config.parent_dir) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+28
to
32
|
||||||||||||||||||||||||||||||||||||||||
| Use --all-completed to archive all tasks with status 'completed' in one command. | |
| """ | |
| config = ctx.obj["config"] | |
| manager = RepositoryManager(config.parent_dir) | |
| Use --all-completed to archive all tasks with status 'completed' in one command. | |
| Note: --all-completed cannot be used together with explicit TASK_IDS. | |
| """ | |
| config = ctx.obj["config"] | |
| manager = RepositoryManager(config.parent_dir) | |
| # Disallow using --all-completed together with explicit task IDs to avoid confusion | |
| if all_completed and task_ids: | |
| click.secho( | |
| "Error: --all-completed cannot be used together with TASK_IDS. " | |
| "Either specify task IDs, or use --all-completed without IDs.", | |
| fg="red", | |
| err=True, | |
| ) | |
| ctx.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import. The sys module is imported but never used in this file. Remove this unused import.