Tighten token CLI commands

This commit is contained in:
mpabi
2026-04-27 21:23:04 +02:00
parent a98159d062
commit 77f9f1ccf4
2 changed files with 27 additions and 40 deletions
+16 -15
View File
@@ -43,10 +43,10 @@ Pobieramy z API metadane tokena:
Sprawdzamy zgodnosc remote i store: Sprawdzamy zgodnosc remote i store:
```bash ```bash
./rvctl tokens compare ./rvctl tokens cmp
``` ```
Po poprawnej synchronizacji `compare` powinien pokazac `*` przy `r1`. Po poprawnej synchronizacji `compare`/`cmp` powinien pokazac `*` przy `r1`.
## Dwa Zrodla ## Dwa Zrodla
@@ -60,8 +60,8 @@ Kierunki sa jawne:
- `sync remote r1` czyta git remote i zapisuje rekord do `tokens.json` - `sync remote r1` czyta git remote i zapisuje rekord do `tokens.json`
- `sync store r1` czyta `tokens.json` i zapisuje auth do git remota - `sync store r1` czyta `tokens.json` i zapisuje auth do git remota
- `update r1` nie synchronizuje sekretu, tylko odswieza metadane z API - `update r1` nie synchronizuje sekretu, tylko odswieza metadane z API
- `remove remote r1` usuwa git remote - `remove remote r1` albo `rm remote r1` usuwa git remote
- `remove store r1` usuwa rekord z `tokens.json` - `remove store r1` albo `rm store r1` usuwa rekord z `tokens.json`
## Listowanie ## Listowanie
@@ -151,10 +151,11 @@ Ta komenda nie zmienia git remota i nie kopiuje sekretu.
## Porownanie ## Porownanie
`compare` sprawdza zgodnosc store i remote: `compare` sprawdza zgodnosc store i remote. Skrot: `cmp`.
```bash ```bash
./rvctl tokens compare ./rvctl tokens compare
./rvctl tokens cmp
``` ```
Marker w kolumnie `token_ref`: Marker w kolumnie `token_ref`:
@@ -173,12 +174,12 @@ Po pierwszej konfiguracji wygodny tryb pracy to trzymanie tokena tylko w
`tokens.json`. `tokens.json`.
```bash ```bash
./rvctl tokens remove remote r1 ./rvctl tokens rm remote r1
./rvctl tokens list store ./rvctl tokens list store
./rvctl tokens compare ./rvctl tokens cmp
``` ```
Wtedy `compare` pokazuje `S`, a `list store` nadal pokazuje znane metadane Wtedy `compare`/`cmp` pokazuje `S`, a `list store` nadal pokazuje znane metadane
tokenu. Gdy trzeba wykonac operacje git przez remote, odtworz remote: tokenu. Gdy trzeba wykonac operacje git przez remote, odtworz remote:
```bash ```bash
@@ -188,7 +189,7 @@ tokenu. Gdy trzeba wykonac operacje git przez remote, odtworz remote:
Po operacji mozna go znowu usunac: Po operacji mozna go znowu usunac:
```bash ```bash
./rvctl tokens remove remote r1 ./rvctl tokens rm remote r1
``` ```
## Usuwanie ## Usuwanie
@@ -196,16 +197,16 @@ Po operacji mozna go znowu usunac:
Usuwaj tylko to miejsce, ktore naprawde chcesz wyczyscic: Usuwaj tylko to miejsce, ktore naprawde chcesz wyczyscic:
```bash ```bash
./rvctl tokens remove remote r1 ./rvctl tokens rm remote r1
./rvctl tokens remove store r1 ./rvctl tokens rm store r1
./rvctl tokens remove both r1 ./rvctl tokens rm both r1
``` ```
Znaczenie: Znaczenie:
- `remove remote` usuwa git remote i sekret z `.git/config`, ale zostawia store - `remove remote` / `rm remote` usuwa git remote i sekret z `.git/config`, ale zostawia store
- `remove store` usuwa rekord z `tokens.json`, ale nie dotyka git remota - `remove store` / `rm store` usuwa rekord z `tokens.json`, ale nie dotyka git remota
- `remove both` usuwa oba miejsca - `remove both` / `rm both` usuwa oba miejsca
## Inne Repo ## Inne Repo
+11 -25
View File
@@ -2582,7 +2582,7 @@ def print_main_overview(config_path: Path) -> None:
["list-cards", "[series]", "list cards in a selected series"], ["list-cards", "[series]", "list cards in a selected series"],
["tmux-container", "[series] [card]", "start tmux with container in pane 0"], ["tmux-container", "[series] [card]", "start tmux with container in pane 0"],
["submission", "[series] [card] --class K --nick N", "prepare answer repo and student branch"], ["submission", "[series] [card] --class K --nick N", "prepare answer repo and student branch"],
["tokens", "list|scan|compare|sync|update|remove|add|read|stats|write", "manage tokens.json and Git remote credentials"], ["tokens", "list|compare|cmp|sync|update|remove|rm|add|read|stats|write", "manage tokens.json and Git remote credentials"],
], ],
) )
print() print()
@@ -2619,14 +2619,13 @@ def print_tokens_overview() -> None:
["command", "common options", "direction", "purpose"], ["command", "common options", "direction", "purpose"],
[ [
["list", "store|remote|both", "read-only", "list one source without comparing it"], ["list", "store|remote|both", "read-only", "list one source without comparing it"],
["scan", "[--repo PATH]", "read-only", "diagnose Git remotes as auth/plain/unsupported"], ["compare/cmp", "[--repo PATH]", "read-only", "compare remote/store with marker and auth masks"],
["compare", "[--repo PATH]", "read-only", "compare remote/store with marker and auth masks"],
["add", "REMOTE_ID", "tokens.json", "add an empty token skeleton for manual editing"], ["add", "REMOTE_ID", "tokens.json", "add an empty token skeleton for manual editing"],
["read", "[--server ENDPOINT]", "tokens.json", "show servers, remote ids and tokens"], ["read", "[--server ENDPOINT]", "tokens.json", "show servers, remote ids and tokens"],
["stats", "[--repo PATH]", "repo + tokens.json", "compare remote URLs with local token store"], ["stats", "[--repo PATH]", "repo + tokens.json", "compare remote URLs with local token store"],
["sync remote", "REMOTE_ID [--repo PATH]", "repo -> tokens.json", "copy one remote URL into the store"], ["sync remote", "REMOTE_ID [--repo PATH]", "repo -> tokens.json", "copy one remote URL into the store"],
["sync store", "REMOTE_ID [--repo PATH]", "tokens.json -> repo", "write one store record into a remote URL"], ["sync store", "REMOTE_ID [--repo PATH]", "tokens.json -> repo", "write one store record into a remote URL"],
["remove", "store|remote|both REMOTE_ID", "selected", "remove token store record or Git remote"], ["remove/rm", "store|remote|both REMOTE_ID", "selected", "remove token store record or Git remote"],
["write", "--remote R [--replace]", "tokens.json -> repo", "write selected token into a remote URL"], ["write", "--remote R [--replace]", "tokens.json -> repo", "write selected token into a remote URL"],
["update", "REMOTE_ID", "API -> tokens.json", "refresh valid/scope/org/repo metadata"], ["update", "REMOTE_ID", "API -> tokens.json", "refresh valid/scope/org/repo metadata"],
], ],
@@ -2638,15 +2637,13 @@ def print_tokens_overview() -> None:
[ [
["list token store", "./rvctl tokens list store"], ["list token store", "./rvctl tokens list store"],
["list launcher remotes", "./rvctl tokens list remote"], ["list launcher remotes", "./rvctl tokens list remote"],
["scan launcher remotes", "./rvctl tokens scan"], ["compare launcher state", "./rvctl tokens cmp"],
["compare launcher state", "./rvctl tokens compare"],
["read remote r1 into store", "./rvctl tokens sync remote r1"], ["read remote r1 into store", "./rvctl tokens sync remote r1"],
["refresh r1 metadata", "./rvctl tokens update r1"], ["refresh r1 metadata", "./rvctl tokens update r1"],
["write store r1 to remote", "./rvctl tokens sync store r1 --repo PATH"], ["write store r1 to remote", "./rvctl tokens sync store r1 --repo PATH"],
["remove r1 from store", "./rvctl tokens remove store r1"], ["remove r1 from store", "./rvctl tokens rm store r1"],
["remove Git remote r1", "./rvctl tokens remove remote r1"], ["remove Git remote r1", "./rvctl tokens rm remote r1"],
["scan selected card", "./rvctl tokens scan --repo ~/dev/workspace/rv/series/inf/03"], ["compare selected card", "./rvctl tokens cmp --repo ~/dev/workspace/rv/series/inf/03"],
["compare selected card", "./rvctl tokens compare --repo ~/dev/workspace/rv/series/inf/03"],
["stats selected card", "./rvctl tokens stats --repo ~/dev/workspace/rv/series/inf/03"], ["stats selected card", "./rvctl tokens stats --repo ~/dev/workspace/rv/series/inf/03"],
["write auth to r1", "./rvctl tokens write --repo PATH --remote r1 --server URL"], ["write auth to r1", "./rvctl tokens write --repo PATH --remote r1 --server URL"],
], ],
@@ -2739,18 +2736,9 @@ def build_parser() -> argparse.ArgumentParser:
tokens_parser = subparsers.add_parser("tokens", help="Manage local token store and repo remotes.") tokens_parser = subparsers.add_parser("tokens", help="Manage local token store and repo remotes.")
tokens_subparsers = tokens_parser.add_subparsers(dest="tokens_command", required=True) tokens_subparsers = tokens_parser.add_subparsers(dest="tokens_command", required=True)
tokens_scan_parser = tokens_subparsers.add_parser(
"scan",
help="Scan Git remotes and print auth/plain/unsupported URL diagnostics.",
)
tokens_scan_parser.add_argument(
"--repo",
help="Path inside a target git repo. Default: repo containing rvctl.",
)
tokens_scan_parser.add_argument("--server", help="Filter output to one server endpoint.")
tokens_compare_parser = tokens_subparsers.add_parser( tokens_compare_parser = tokens_subparsers.add_parser(
"compare", "compare",
aliases=["cmp"],
help="Compare repo remotes with tokens.json and print paired token rows.", help="Compare repo remotes with tokens.json and print paired token rows.",
) )
tokens_compare_parser.add_argument( tokens_compare_parser.add_argument(
@@ -2816,6 +2804,7 @@ def build_parser() -> argparse.ArgumentParser:
tokens_remove_parser = tokens_subparsers.add_parser( tokens_remove_parser = tokens_subparsers.add_parser(
"remove", "remove",
aliases=["rm"],
help="Remove a token store record, a Git remote, or both.", help="Remove a token store record, a Git remote, or both.",
) )
tokens_remove_parser.add_argument("target", choices=["store", "remote", "both"], help="Where to remove REMOTE_ID from.") tokens_remove_parser.add_argument("target", choices=["store", "remote", "both"], help="Where to remove REMOTE_ID from.")
@@ -2888,10 +2877,7 @@ def main() -> int:
print_submission_plan(config, args) print_submission_plan(config, args)
return 0 return 0
if args.command == "tokens": if args.command == "tokens":
if args.tokens_command == "scan": if args.tokens_command in {"compare", "cmp"}:
run_tokens_scan(config, args)
return 0
if args.tokens_command == "compare":
run_tokens_compare(config, args) run_tokens_compare(config, args)
return 0 return 0
if args.tokens_command == "list": if args.tokens_command == "list":
@@ -2909,7 +2895,7 @@ def main() -> int:
if args.tokens_command == "sync": if args.tokens_command == "sync":
run_tokens_sync(config, args) run_tokens_sync(config, args)
return 0 return 0
if args.tokens_command == "remove": if args.tokens_command in {"remove", "rm"}:
run_tokens_remove(config, args) run_tokens_remove(config, args)
return 0 return 0
if args.tokens_command == "write": if args.tokens_command == "write":