Add task shortcuts for default card
This commit is contained in:
@@ -341,10 +341,11 @@ answer_repo lab-rv32i-strlen-bss-data-stack
|
|||||||
answer_url http://77.90.8.171:3001/c2025-1a-inf/lab-rv32i-strlen-bss-data-stack.git
|
answer_url http://77.90.8.171:3001/c2025-1a-inf/lab-rv32i-strlen-bss-data-stack.git
|
||||||
```
|
```
|
||||||
|
|
||||||
Następnie wylistuj zadania w karcie:
|
Następnie wylistuj zadania w karcie. Skrót `tasks` działa na domyślnej serii i
|
||||||
|
karcie z `workspace.json`, czyli tutaj na `inf bss`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./rvctl series cards tasks list inf bss
|
./rvctl tasks list
|
||||||
```
|
```
|
||||||
|
|
||||||
Przykładowy wynik:
|
Przykładowy wynik:
|
||||||
@@ -361,7 +362,7 @@ tworzy branch pracy w formacie `<login>T<numer_zadania>a` i ustawia mu upstream
|
|||||||
na `r1a/<branch>`:
|
na `r1a/<branch>`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./rvctl series cards tasks switch inf bss 4
|
./rvctl tasks switch 4
|
||||||
```
|
```
|
||||||
|
|
||||||
Dla użytkownika `u1` i zadania `task4_stack_strlen` branch będzie miał nazwę:
|
Dla użytkownika `u1` i zadania `task4_stack_strlen` branch będzie miał nazwę:
|
||||||
|
|||||||
@@ -215,6 +215,9 @@ Komendy:
|
|||||||
- `series cards tasks list SERIES CARD`
|
- `series cards tasks list SERIES CARD`
|
||||||
- `series cards tasks show SERIES CARD TASK`
|
- `series cards tasks show SERIES CARD TASK`
|
||||||
- `series cards tasks switch SERIES CARD TASK`
|
- `series cards tasks switch SERIES CARD TASK`
|
||||||
|
- `tasks list [CARD|SERIES CARD]`
|
||||||
|
- `tasks show TASK|CARD TASK|SERIES CARD TASK`
|
||||||
|
- `tasks switch TASK|CARD TASK|SERIES CARD TASK`
|
||||||
- `tokens scan`
|
- `tokens scan`
|
||||||
- `tokens compare`
|
- `tokens compare`
|
||||||
- `tokens read`
|
- `tokens read`
|
||||||
@@ -486,6 +489,45 @@ końcówki `a`. Dla użytkownika `u1` i zadania `task4_stack_strlen` będzie to
|
|||||||
./rvctl series cards tasks switch inf bss 4
|
./rvctl series cards tasks switch inf bss 4
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## `tasks list`
|
||||||
|
|
||||||
|
Skrót do listowania zadań z domyślnej karty z `workspace.json`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./rvctl tasks list
|
||||||
|
```
|
||||||
|
|
||||||
|
Opcjonalnie można wskazać kartę albo serię i kartę:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./rvctl tasks list bss
|
||||||
|
./rvctl tasks list inf bss
|
||||||
|
```
|
||||||
|
|
||||||
|
## `tasks show TASK`
|
||||||
|
|
||||||
|
Skrót do podglądu zadania z domyślnej karty.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./rvctl tasks show 4
|
||||||
|
./rvctl tasks show bss 4
|
||||||
|
./rvctl tasks show inf bss 4
|
||||||
|
```
|
||||||
|
|
||||||
|
## `tasks switch TASK`
|
||||||
|
|
||||||
|
Skrót do przełączenia na branch odpowiedzi dla zadania z domyślnej karty.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./rvctl tasks switch 4
|
||||||
|
```
|
||||||
|
|
||||||
|
Ta komenda działa tak samo jak pełna forma:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./rvctl series cards tasks switch inf bss 4
|
||||||
|
```
|
||||||
|
|
||||||
## `list-series`
|
## `list-series`
|
||||||
|
|
||||||
Alias kompatybilności dla `series list`.
|
Alias kompatybilności dla `series list`.
|
||||||
|
|||||||
+21
-2
@@ -22,8 +22,8 @@ workspace.
|
|||||||
./rvctl series list
|
./rvctl series list
|
||||||
./rvctl series cards list inf
|
./rvctl series cards list inf
|
||||||
./rvctl series cards fetch inf bss
|
./rvctl series cards fetch inf bss
|
||||||
./rvctl series cards tasks list inf bss
|
./rvctl tasks list
|
||||||
./rvctl series cards tasks switch inf bss 1
|
./rvctl tasks switch 1
|
||||||
```
|
```
|
||||||
|
|
||||||
Dla karty `bss` właściwym repo jest `lab-rv32i-strlen-bss-data-stack`.
|
Dla karty `bss` właściwym repo jest `lab-rv32i-strlen-bss-data-stack`.
|
||||||
@@ -126,6 +126,7 @@ store tokenów i zadania, na przykład `u1T1a`.
|
|||||||
## Zadania w karcie
|
## Zadania w karcie
|
||||||
|
|
||||||
Zadania są częścią karty, dlatego trzymamy je pod `series cards tasks`.
|
Zadania są częścią karty, dlatego trzymamy je pod `series cards tasks`.
|
||||||
|
Do codziennej pracy z domyślną kartą można używać krótszego namespace `tasks`.
|
||||||
|
|
||||||
### `series cards tasks list SERIES CARD`
|
### `series cards tasks list SERIES CARD`
|
||||||
|
|
||||||
@@ -135,6 +136,12 @@ Listuje zadania dostępne w konkretnej karcie.
|
|||||||
./rvctl series cards tasks list inf bss
|
./rvctl series cards tasks list inf bss
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Skrót dla domyślnej karty:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./rvctl tasks list
|
||||||
|
```
|
||||||
|
|
||||||
Przykładowy wynik:
|
Przykładowy wynik:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
@@ -152,6 +159,12 @@ Pokazuje informacje o konkretnym zadaniu w karcie.
|
|||||||
./rvctl series cards tasks show inf bss task1
|
./rvctl series cards tasks show inf bss task1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Skrót dla domyślnej karty:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./rvctl tasks show 1
|
||||||
|
```
|
||||||
|
|
||||||
### `series cards tasks switch SERIES CARD TASK`
|
### `series cards tasks switch SERIES CARD TASK`
|
||||||
|
|
||||||
Tworzy albo przełącza lokalny branch pracy dla wybranego zadania.
|
Tworzy albo przełącza lokalny branch pracy dla wybranego zadania.
|
||||||
@@ -160,6 +173,12 @@ Tworzy albo przełącza lokalny branch pracy dla wybranego zadania.
|
|||||||
./rvctl series cards tasks switch inf bss 4
|
./rvctl series cards tasks switch inf bss 4
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Skrót dla domyślnej karty:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./rvctl tasks switch 4
|
||||||
|
```
|
||||||
|
|
||||||
Nazwa brancha jest liczona automatycznie z użytkownika w `tokens.json` i numeru
|
Nazwa brancha jest liczona automatycznie z użytkownika w `tokens.json` i numeru
|
||||||
zadania. Dla użytkownika `u1` i zadania `task4_stack_strlen` powstanie:
|
zadania. Dla użytkownika `u1` i zadania `task4_stack_strlen` powstanie:
|
||||||
|
|
||||||
|
|||||||
@@ -2896,6 +2896,49 @@ def run_series(config: WorkspaceConfig, args: argparse.Namespace) -> None:
|
|||||||
raise SystemExit(f"Unsupported series cards tasks command: {args.tasks_command}")
|
raise SystemExit(f"Unsupported series cards tasks command: {args.tasks_command}")
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_task_command_selector(
|
||||||
|
config: WorkspaceConfig,
|
||||||
|
values: list[str],
|
||||||
|
needs_task: bool = False,
|
||||||
|
) -> tuple[str, str, str | None]:
|
||||||
|
if not needs_task:
|
||||||
|
if len(values) > 2:
|
||||||
|
raise SystemExit("Pass at most '<series> <card>' for tasks list.")
|
||||||
|
series_arg = values[0] if values else None
|
||||||
|
card_arg = values[1] if len(values) == 2 else None
|
||||||
|
series_name, card_name = resolve_selector(config, series_arg, card_arg)
|
||||||
|
return series_name, card_name, None
|
||||||
|
|
||||||
|
if not values:
|
||||||
|
raise SystemExit("Missing task. Use: ./rvctl tasks switch 4")
|
||||||
|
if len(values) > 3:
|
||||||
|
raise SystemExit("Pass '<task>', '<card> <task>' or '<series> <card> <task>'.")
|
||||||
|
if len(values) == 1:
|
||||||
|
series_name, card_name = resolve_selector(config, None, None)
|
||||||
|
return series_name, card_name, values[0]
|
||||||
|
if len(values) == 2:
|
||||||
|
series_name, card_name = resolve_selector(config, values[0], None)
|
||||||
|
return series_name, card_name, values[1]
|
||||||
|
series_name, card_name = resolve_selector(config, values[0], values[1])
|
||||||
|
return series_name, card_name, values[2]
|
||||||
|
|
||||||
|
|
||||||
|
def run_tasks(config: WorkspaceConfig, args: argparse.Namespace) -> None:
|
||||||
|
if args.tasks_command == "list":
|
||||||
|
series_name, card_name, _ = resolve_task_command_selector(config, args.selector)
|
||||||
|
print_card_tasks(config, series_name, card_name)
|
||||||
|
return
|
||||||
|
if args.tasks_command == "show":
|
||||||
|
series_name, card_name, task_name = resolve_task_command_selector(config, args.selector, needs_task=True)
|
||||||
|
print_card_task(config, series_name, card_name, task_name or "")
|
||||||
|
return
|
||||||
|
if args.tasks_command == "switch":
|
||||||
|
series_name, card_name, task_name = resolve_task_command_selector(config, args.selector, needs_task=True)
|
||||||
|
print_key_values(switch_card_task(config, series_name, card_name, task_name or "", args.branch, args.dry_run))
|
||||||
|
return
|
||||||
|
raise SystemExit(f"Unsupported tasks command: {args.tasks_command}")
|
||||||
|
|
||||||
|
|
||||||
def print_submission_plan(config: WorkspaceConfig, args: argparse.Namespace) -> None:
|
def print_submission_plan(config: WorkspaceConfig, args: argparse.Namespace) -> None:
|
||||||
series_name, card_name = resolve_selector(config, args.series, args.card)
|
series_name, card_name = resolve_selector(config, args.series, args.card)
|
||||||
selector = f"{series_name}/{card_name}"
|
selector = f"{series_name}/{card_name}"
|
||||||
@@ -3128,6 +3171,7 @@ def print_main_overview(config_path: Path) -> None:
|
|||||||
[
|
[
|
||||||
["show-config", "", "show resolved paths and Git defaults"],
|
["show-config", "", "show resolved paths and Git defaults"],
|
||||||
["series", "list|cards|fetch|tasks", "work with series, cards and tasks"],
|
["series", "list|cards|fetch|tasks", "work with series, cards and tasks"],
|
||||||
|
["tasks", "list|show|switch", "shortcut for tasks in the default card"],
|
||||||
["list-series", "", "compat alias for series list"],
|
["list-series", "", "compat alias for series list"],
|
||||||
["list-cards", "[series]", "compat alias for series cards list"],
|
["list-cards", "[series]", "compat alias for series cards list"],
|
||||||
["tmux-container", "[series] [card]", "start tmux with container in pane 0"],
|
["tmux-container", "[series] [card]", "start tmux with container in pane 0"],
|
||||||
@@ -3144,7 +3188,8 @@ def print_main_overview(config_path: Path) -> None:
|
|||||||
["2", "./rvctl series list", "choose a series"],
|
["2", "./rvctl series list", "choose a series"],
|
||||||
["3", "./rvctl series cards list inf", "choose a card"],
|
["3", "./rvctl series cards list inf", "choose a card"],
|
||||||
["4", "./rvctl series cards fetch inf bss", "fetch card and prepare r1a"],
|
["4", "./rvctl series cards fetch inf bss", "fetch card and prepare r1a"],
|
||||||
["5", "./rvctl series cards tasks list inf bss", "list card tasks"],
|
["5", "./rvctl tasks list", "list tasks from the default card"],
|
||||||
|
["6", "./rvctl tasks switch 4", "switch to the answer branch for task 4"],
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
print()
|
print()
|
||||||
@@ -3244,6 +3289,20 @@ def build_parser() -> argparse.ArgumentParser:
|
|||||||
cards_parser = subparsers.add_parser("list-cards", help="List cards in a series.")
|
cards_parser = subparsers.add_parser("list-cards", help="List cards in a series.")
|
||||||
cards_parser.add_argument("series", nargs="?", help="Series id, for example 'inf'.")
|
cards_parser.add_argument("series", nargs="?", help="Series id, for example 'inf'.")
|
||||||
|
|
||||||
|
tasks_parser = subparsers.add_parser("tasks", help="Shortcut for tasks in the default card.")
|
||||||
|
tasks_subparsers = tasks_parser.add_subparsers(dest="tasks_command", required=True)
|
||||||
|
|
||||||
|
tasks_short_list_parser = tasks_subparsers.add_parser("list", help="List tasks from the default or selected card.")
|
||||||
|
tasks_short_list_parser.add_argument("selector", nargs="*", help="Optional card selector: [card] or [series card].")
|
||||||
|
|
||||||
|
tasks_short_show_parser = tasks_subparsers.add_parser("show", help="Show one task from the default or selected card.")
|
||||||
|
tasks_short_show_parser.add_argument("selector", nargs="+", help="Task selector: task, card task, or series card task.")
|
||||||
|
|
||||||
|
tasks_short_switch_parser = tasks_subparsers.add_parser("switch", help="Create or switch to the answer branch for a task.")
|
||||||
|
tasks_short_switch_parser.add_argument("selector", nargs="+", help="Task selector: task, card task, or series card task.")
|
||||||
|
tasks_short_switch_parser.add_argument("--branch", help="Override the branch name.")
|
||||||
|
tasks_short_switch_parser.add_argument("--dry-run", action="store_true", help="Print plan without switching branches.")
|
||||||
|
|
||||||
tmux_parser = subparsers.add_parser(
|
tmux_parser = subparsers.add_parser(
|
||||||
"tmux-container",
|
"tmux-container",
|
||||||
help="Create a tmux session with pane 0 running the container shell for a selected card.",
|
help="Create a tmux session with pane 0 running the container shell for a selected card.",
|
||||||
@@ -3478,6 +3537,9 @@ def main() -> int:
|
|||||||
if args.command == "list-cards":
|
if args.command == "list-cards":
|
||||||
print_cards(config, args.series)
|
print_cards(config, args.series)
|
||||||
return 0
|
return 0
|
||||||
|
if args.command == "tasks":
|
||||||
|
run_tasks(config, args)
|
||||||
|
return 0
|
||||||
if args.command == "tmux-container":
|
if args.command == "tmux-container":
|
||||||
run_tmux_container(config, args)
|
run_tmux_container(config, args)
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user