okf-cli 0.5.3__tar.gz → 0.5.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {okf_cli-0.5.3 → okf_cli-0.5.4}/PKG-INFO +10 -6
- {okf_cli-0.5.3 → okf_cli-0.5.4}/README.md +9 -5
- {okf_cli-0.5.3 → okf_cli-0.5.4}/openwiki/architecture.md +5 -2
- {okf_cli-0.5.3 → okf_cli-0.5.4}/openwiki/workflows.md +1 -1
- {okf_cli-0.5.3 → okf_cli-0.5.4}/pyproject.toml +1 -1
- {okf_cli-0.5.3 → okf_cli-0.5.4}/src/okf/api.py +45 -14
- okf_cli-0.5.4/src/okf/commands/list.py +39 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/tests/test_api.py +110 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/tests/test_cli.py +57 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/uv.lock +1 -1
- okf_cli-0.5.3/src/okf/commands/list.py +0 -24
- {okf_cli-0.5.3 → okf_cli-0.5.4}/.github/workflows/test.yml +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/.gitignore +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/.last-update.json +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/AGENTS.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/LICENSE +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/OKF_SPEC.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/.okfignore +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/README.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/blank-line/no-blank.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/blank-line/with-blank.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/datasets/sales.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/domain.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/loose/deep/no-heading.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/loose/no-desc.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/loose/no-title.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/playbooks/incident-response.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/playbooks/oncall-guide.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/smoke-ignore.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/tables/customers.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/tables/orders.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/tables/partitions/2026/q1/jan/january.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/example/tables/partitions/daily.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/openwiki/domain-model.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/openwiki/operations.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/openwiki/quickstart.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/openwiki/testing.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/skills/okf-cli/SKILL.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/skills/writing-knowledge-base/SKILL.md +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/src/okf/__init__.py +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/src/okf/cli.py +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/src/okf/commands/__init__.py +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/src/okf/commands/bundle.py +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/src/okf/commands/read.py +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/src/okf/commands/validate.py +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/src/okf/core.py +0 -0
- {okf_cli-0.5.3 → okf_cli-0.5.4}/tests/test_core.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: okf-cli
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.4
|
|
4
4
|
Summary: Open Knowledge Format tooling
|
|
5
5
|
License: MIT License
|
|
6
6
|
|
|
@@ -34,7 +34,7 @@ Description-Content-Type: text/markdown
|
|
|
34
34
|
|
|
35
35
|
Converts plain markdown into [OKF](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md)-conformant knowledge bundles. Domain experts write the content, `okf bundle` generates frontmatter, type, timestamps, and index files.
|
|
36
36
|
|
|
37
|
-
Also validates bundles, lists
|
|
37
|
+
Also validates bundles, lists concepts, reads concepts by ID, and reports version.
|
|
38
38
|
|
|
39
39
|
## Install
|
|
40
40
|
|
|
@@ -77,18 +77,22 @@ okf bundle example bundled --default-type reference --force --strict
|
|
|
77
77
|
|
|
78
78
|
**Link checking**: scans body links to local `.md` targets. Missing or out-of-bundle links warn by default, fail with `--strict`.
|
|
79
79
|
|
|
80
|
-
### `okf list` — list
|
|
80
|
+
### `okf list` — list concepts in a bundle
|
|
81
81
|
|
|
82
82
|
```
|
|
83
83
|
okf list <directory>
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
Prints
|
|
86
|
+
Prints a table of concepts with ID, type, title, and description. Requires valid OKF bundle.
|
|
87
87
|
|
|
88
88
|
```bash
|
|
89
89
|
okf list example_knowledge_base/
|
|
90
|
-
#
|
|
91
|
-
#
|
|
90
|
+
# ┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━┓
|
|
91
|
+
# ┃ ID ┃ Type ┃ Title ┃ Description ┃
|
|
92
|
+
# ┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━┩
|
|
93
|
+
# │ datasets/sales │ datasets │ Sales │ Sales data. │
|
|
94
|
+
# │ tables/orders │ tables │ Orders │ One row. │
|
|
95
|
+
# └────────────────┴──────────┴────────┴─────────────┘
|
|
92
96
|
```
|
|
93
97
|
|
|
94
98
|
### `okf read` — read a concept by ID
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Converts plain markdown into [OKF](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md)-conformant knowledge bundles. Domain experts write the content, `okf bundle` generates frontmatter, type, timestamps, and index files.
|
|
4
4
|
|
|
5
|
-
Also validates bundles, lists
|
|
5
|
+
Also validates bundles, lists concepts, reads concepts by ID, and reports version.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -45,18 +45,22 @@ okf bundle example bundled --default-type reference --force --strict
|
|
|
45
45
|
|
|
46
46
|
**Link checking**: scans body links to local `.md` targets. Missing or out-of-bundle links warn by default, fail with `--strict`.
|
|
47
47
|
|
|
48
|
-
### `okf list` — list
|
|
48
|
+
### `okf list` — list concepts in a bundle
|
|
49
49
|
|
|
50
50
|
```
|
|
51
51
|
okf list <directory>
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
Prints
|
|
54
|
+
Prints a table of concepts with ID, type, title, and description. Requires valid OKF bundle.
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
57
|
okf list example_knowledge_base/
|
|
58
|
-
#
|
|
59
|
-
#
|
|
58
|
+
# ┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━┓
|
|
59
|
+
# ┃ ID ┃ Type ┃ Title ┃ Description ┃
|
|
60
|
+
# ┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━┩
|
|
61
|
+
# │ datasets/sales │ datasets │ Sales │ Sales data. │
|
|
62
|
+
# │ tables/orders │ tables │ Orders │ One row. │
|
|
63
|
+
# └────────────────┴──────────┴────────┴─────────────┘
|
|
60
64
|
```
|
|
61
65
|
|
|
62
66
|
### `okf read` — read a concept by ID
|
|
@@ -23,6 +23,7 @@ Public functions and return types:
|
|
|
23
23
|
| `convert_file(input_file, output_file, type_)` | `BundleResult` | Convert single markdown file to OKF concept (timestamp from mtime) |
|
|
24
24
|
| `convert_content(content, output_file, type_)` | `BundleResult` | Convert raw markdown string to OKF concept (no timestamp) |
|
|
25
25
|
| `list_concepts(bundle_dir)` | `list[str]` | Conformance-gated concept ID listing |
|
|
26
|
+
| `list_entries(bundle_dir)` | `list[dict]` | Conformance-gated concept metadata (id, type, title, description) |
|
|
26
27
|
| `show_concept(bundle_dir, concept_id)` | `ConceptContent` | Conformance-gated concept read with path traversal guard |
|
|
27
28
|
| `validate(bundle_dir)` | `ValidateResult` | Conformance check with `.ok` property |
|
|
28
29
|
|
|
@@ -59,9 +60,11 @@ Each file imports from `okf.api` and calls the corresponding function, translati
|
|
|
59
60
|
1. Call `check_conformance` once.
|
|
60
61
|
1. Return `ValidateResult` with file count, errors, and warnings.
|
|
61
62
|
|
|
62
|
-
### `okf list` and `okf read` (via `api.
|
|
63
|
+
### `okf list` and `okf read` (via `api.list_entries()` / `api.show_concept()`)
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
`okf list` renders the metadata returned by `api.list_entries()` as a Rich table (ID, type, title, description). `okf read` looks up a single concept by ID via `api.show_concept()`.
|
|
66
|
+
|
|
67
|
+
Both reading paths first run `check_conformance`. If directory is non-conformant, they raise `ValueError`.
|
|
65
68
|
|
|
66
69
|
Reason: reading APIs should not return misleading data from broken bundles.
|
|
67
70
|
|
|
@@ -51,7 +51,7 @@ uv run okf list <output-dir>
|
|
|
51
51
|
uv run okf read <output-dir> <concept-id>
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
`list`
|
|
54
|
+
`list` prints a table of concepts (ID, type, title, description); `read` prints full concept markdown.
|
|
55
55
|
|
|
56
56
|
## Contributor workflow
|
|
57
57
|
|
|
@@ -435,6 +435,27 @@ def bundle(
|
|
|
435
435
|
)
|
|
436
436
|
|
|
437
437
|
|
|
438
|
+
def _iter_concept_files(dir_path: Path):
|
|
439
|
+
"""Yield (concept_id, file_path) for every concept in a bundle.
|
|
440
|
+
|
|
441
|
+
Validates the directory and conformance before iterating. Skips
|
|
442
|
+
spec-reserved filenames such as ``index.md`` and ``log.md``.
|
|
443
|
+
"""
|
|
444
|
+
if not dir_path.is_dir():
|
|
445
|
+
raise NotADirectoryError(f"'{dir_path}' is not a directory")
|
|
446
|
+
|
|
447
|
+
errors, _warnings = check_conformance(dir_path)
|
|
448
|
+
if errors:
|
|
449
|
+
raise ValueError("not an OKF-conformant bundle:\n" + "\n".join(errors))
|
|
450
|
+
|
|
451
|
+
for f in sorted(dir_path.rglob("*.md")):
|
|
452
|
+
if f.name.lower() in SPEC_RESERVED:
|
|
453
|
+
continue
|
|
454
|
+
rel = f.relative_to(dir_path)
|
|
455
|
+
cid = str(rel.parent / rel.stem) if rel.parent != Path(".") else rel.stem
|
|
456
|
+
yield cid, f
|
|
457
|
+
|
|
458
|
+
|
|
438
459
|
def list_concepts(bundle_dir: str | Path) -> list[str]:
|
|
439
460
|
"""List all concept IDs in an OKF-conformant bundle.
|
|
440
461
|
|
|
@@ -447,24 +468,34 @@ def list_concepts(bundle_dir: str | Path) -> list[str]:
|
|
|
447
468
|
Raises:
|
|
448
469
|
ValueError: If the directory is not a valid OKF bundle.
|
|
449
470
|
"""
|
|
450
|
-
|
|
471
|
+
return [cid for cid, _f in _iter_concept_files(Path(bundle_dir))]
|
|
451
472
|
|
|
452
|
-
if not dir_path.is_dir():
|
|
453
|
-
raise NotADirectoryError(f"'{dir_path}' is not a directory")
|
|
454
473
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
raise ValueError("not an OKF-conformant bundle:\n" + "\n".join(errors))
|
|
474
|
+
def list_entries(bundle_dir: str | Path) -> list[dict[str, str]]:
|
|
475
|
+
"""List all concepts with their frontmatter metadata.
|
|
458
476
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
if f.name.lower() in SPEC_RESERVED:
|
|
462
|
-
continue
|
|
463
|
-
rel = f.relative_to(dir_path)
|
|
464
|
-
cid = str(rel.parent / rel.stem) if rel.parent != Path(".") else rel.stem
|
|
465
|
-
cids.append(cid)
|
|
477
|
+
Args:
|
|
478
|
+
bundle_dir: Path to an OKF bundle directory.
|
|
466
479
|
|
|
467
|
-
|
|
480
|
+
Returns:
|
|
481
|
+
Sorted list of dicts with keys ``id``, ``type``, ``title``,
|
|
482
|
+
``description``. ``title`` and ``description`` are empty strings
|
|
483
|
+
when absent from frontmatter.
|
|
484
|
+
|
|
485
|
+
Raises:
|
|
486
|
+
ValueError: If the directory is not a valid OKF bundle.
|
|
487
|
+
"""
|
|
488
|
+
entries: list[dict[str, str]] = []
|
|
489
|
+
for cid, f in _iter_concept_files(Path(bundle_dir)):
|
|
490
|
+
fm = parse_frontmatter(f.read_text(encoding="utf-8")) or {}
|
|
491
|
+
entries.append({
|
|
492
|
+
"id": cid,
|
|
493
|
+
"type": str(fm.get("type", "")),
|
|
494
|
+
"title": str(fm.get("title", "")),
|
|
495
|
+
"description": str(fm.get("description", "")),
|
|
496
|
+
})
|
|
497
|
+
|
|
498
|
+
return entries
|
|
468
499
|
|
|
469
500
|
|
|
470
501
|
def show_concept(bundle_dir: str | Path, concept_id: str) -> ConceptContent:
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""okf list command."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
from rich.table import Table
|
|
7
|
+
|
|
8
|
+
from okf import api
|
|
9
|
+
from okf.core import console, err_console
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def cmd_list(
|
|
13
|
+
directory: str = typer.Argument(..., help="Directory of the OKF bundle"),
|
|
14
|
+
) -> None:
|
|
15
|
+
"""List concepts in a table with ID, type, title, and description."""
|
|
16
|
+
try:
|
|
17
|
+
entries = api.list_entries(directory)
|
|
18
|
+
except (ValueError, NotADirectoryError) as e:
|
|
19
|
+
err_console.print(f"Error: {e}", style="red")
|
|
20
|
+
raise typer.Exit(code=1)
|
|
21
|
+
|
|
22
|
+
if not entries:
|
|
23
|
+
err_console.print("No concepts found", style="yellow")
|
|
24
|
+
raise typer.Exit(code=1)
|
|
25
|
+
|
|
26
|
+
table = Table(
|
|
27
|
+
"ID",
|
|
28
|
+
"Type",
|
|
29
|
+
"Title",
|
|
30
|
+
"Description",
|
|
31
|
+
caption="Use the ID column with: okf read <bundle> <id>",
|
|
32
|
+
)
|
|
33
|
+
table.columns[0].no_wrap = True
|
|
34
|
+
|
|
35
|
+
for e in entries:
|
|
36
|
+
title = e["title"] if e["title"] else Path(e["id"]).stem
|
|
37
|
+
table.add_row(e["id"], e["type"], title, e["description"])
|
|
38
|
+
|
|
39
|
+
console.print(table)
|
|
@@ -13,6 +13,7 @@ from okf.api import (
|
|
|
13
13
|
convert_content,
|
|
14
14
|
convert_file,
|
|
15
15
|
list_concepts,
|
|
16
|
+
list_entries,
|
|
16
17
|
show_concept,
|
|
17
18
|
validate,
|
|
18
19
|
)
|
|
@@ -639,6 +640,115 @@ class TestListConcepts:
|
|
|
639
640
|
list_concepts(tmp_path / "nope")
|
|
640
641
|
|
|
641
642
|
|
|
643
|
+
# ---------------------------------------------------------------------------
|
|
644
|
+
# list_entries()
|
|
645
|
+
# ---------------------------------------------------------------------------
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
class TestListEntries:
|
|
649
|
+
def test_lists_with_metadata(self, tmp_path: Path):
|
|
650
|
+
src = tmp_path / "src"
|
|
651
|
+
dst = tmp_path / "out"
|
|
652
|
+
src.mkdir()
|
|
653
|
+
_write(
|
|
654
|
+
src,
|
|
655
|
+
{
|
|
656
|
+
"tables/orders.md": "# Orders\n\n> Customer orders.\n\nBody.",
|
|
657
|
+
"datasets/sales.md": "# Sales\n\n> Sales dataset.\n\nBody.",
|
|
658
|
+
},
|
|
659
|
+
)
|
|
660
|
+
bundle(src, dst)
|
|
661
|
+
|
|
662
|
+
entries = list_entries(dst)
|
|
663
|
+
|
|
664
|
+
assert isinstance(entries, list)
|
|
665
|
+
assert all(isinstance(e, dict) for e in entries)
|
|
666
|
+
keys = ("id", "type", "title", "description")
|
|
667
|
+
assert all(k in e for e in entries for k in keys)
|
|
668
|
+
assert {"tables/orders", "datasets/sales"} == {e["id"] for e in entries}
|
|
669
|
+
|
|
670
|
+
def test_entries_have_types(self, tmp_path: Path):
|
|
671
|
+
src = tmp_path / "src"
|
|
672
|
+
dst = tmp_path / "out"
|
|
673
|
+
src.mkdir()
|
|
674
|
+
_write(
|
|
675
|
+
src,
|
|
676
|
+
{
|
|
677
|
+
"tables/a.md": "# A\n\n> Desc.\n\nBody.",
|
|
678
|
+
"playbooks/b.md": "# B\n\n> Playbook.\n\nBody.",
|
|
679
|
+
},
|
|
680
|
+
)
|
|
681
|
+
bundle(src, dst)
|
|
682
|
+
|
|
683
|
+
entries = list_entries(dst)
|
|
684
|
+
by_id = {e["id"]: e for e in entries}
|
|
685
|
+
|
|
686
|
+
assert by_id["tables/a"]["type"] == "tables"
|
|
687
|
+
assert by_id["playbooks/b"]["type"] == "playbooks"
|
|
688
|
+
|
|
689
|
+
def test_missing_title_shows_empty(self, tmp_path: Path):
|
|
690
|
+
src = tmp_path / "src"
|
|
691
|
+
dst = tmp_path / "out"
|
|
692
|
+
src.mkdir()
|
|
693
|
+
_write(src, {"tables/bad.md": "No heading.\n> Desc.\n"})
|
|
694
|
+
bundle(src, dst)
|
|
695
|
+
|
|
696
|
+
entries = list_entries(dst)
|
|
697
|
+
assert entries[0]["title"] == ""
|
|
698
|
+
|
|
699
|
+
def test_missing_description_shows_empty(self, tmp_path: Path):
|
|
700
|
+
# Construct a bundle manually so description is truly absent.
|
|
701
|
+
d = tmp_path / "bundle"
|
|
702
|
+
d.mkdir()
|
|
703
|
+
(d / "tables").mkdir()
|
|
704
|
+
(d / "tables" / "minimal.md").write_text(
|
|
705
|
+
"---\ntype: tables\ntitle: Minimal\n---\n\nJust body."
|
|
706
|
+
)
|
|
707
|
+
|
|
708
|
+
entries = list_entries(d)
|
|
709
|
+
assert entries[0]["description"] == ""
|
|
710
|
+
|
|
711
|
+
def test_excludes_reserved(self, tmp_path: Path):
|
|
712
|
+
src = tmp_path / "src"
|
|
713
|
+
dst = tmp_path / "out"
|
|
714
|
+
src.mkdir()
|
|
715
|
+
_write(src, {"tables/a.md": "# A\n\n> Desc.\n"})
|
|
716
|
+
bundle(src, dst)
|
|
717
|
+
|
|
718
|
+
entries = list_entries(dst)
|
|
719
|
+
ids = {e["id"] for e in entries}
|
|
720
|
+
assert "index" not in ids
|
|
721
|
+
|
|
722
|
+
def test_sorted_order(self, tmp_path: Path):
|
|
723
|
+
src = tmp_path / "src"
|
|
724
|
+
dst = tmp_path / "out"
|
|
725
|
+
src.mkdir()
|
|
726
|
+
_write(
|
|
727
|
+
src,
|
|
728
|
+
{
|
|
729
|
+
"tables/orders.md": "# Orders\n\n> One row.\n",
|
|
730
|
+
"playbooks/incident.md": "# Incident\n\n> Playbook.\n",
|
|
731
|
+
},
|
|
732
|
+
)
|
|
733
|
+
bundle(src, dst)
|
|
734
|
+
|
|
735
|
+
entries = list_entries(dst)
|
|
736
|
+
ids = [e["id"] for e in entries]
|
|
737
|
+
assert ids == sorted(ids)
|
|
738
|
+
|
|
739
|
+
def test_not_conformant(self, tmp_path: Path):
|
|
740
|
+
d = tmp_path / "raw"
|
|
741
|
+
d.mkdir()
|
|
742
|
+
_write(d, {"plain.md": "# Title\n\n> Desc.\n\nBody."})
|
|
743
|
+
|
|
744
|
+
with pytest.raises(ValueError, match="not an OKF-conformant"):
|
|
745
|
+
list_entries(d)
|
|
746
|
+
|
|
747
|
+
def test_not_a_dir(self, tmp_path: Path):
|
|
748
|
+
with pytest.raises(NotADirectoryError):
|
|
749
|
+
list_entries(tmp_path / "nope")
|
|
750
|
+
|
|
751
|
+
|
|
642
752
|
# ---------------------------------------------------------------------------
|
|
643
753
|
# show_concept()
|
|
644
754
|
# ---------------------------------------------------------------------------
|
|
@@ -210,6 +210,63 @@ def test_list_empty_shows_message(tmp_path: Path):
|
|
|
210
210
|
assert "No concepts found" in result.output
|
|
211
211
|
|
|
212
212
|
|
|
213
|
+
def test_list_shows_table(tmp_path: Path):
|
|
214
|
+
d = tmp_path / "bundle"
|
|
215
|
+
d.mkdir()
|
|
216
|
+
_write(
|
|
217
|
+
d,
|
|
218
|
+
{
|
|
219
|
+
"tables/orders.md": (
|
|
220
|
+
"---\n"
|
|
221
|
+
"type: tables\n"
|
|
222
|
+
"title: Orders\n"
|
|
223
|
+
"description: Customer orders.\n"
|
|
224
|
+
"---\n\n"
|
|
225
|
+
"Body."
|
|
226
|
+
),
|
|
227
|
+
"datasets/sales.md": (
|
|
228
|
+
"---\n"
|
|
229
|
+
"type: datasets\n"
|
|
230
|
+
"title: Sales\n"
|
|
231
|
+
"description: Sales data.\n"
|
|
232
|
+
"---\n\n"
|
|
233
|
+
"Body."
|
|
234
|
+
),
|
|
235
|
+
},
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
result = runner.invoke(app, ["list", str(d)])
|
|
239
|
+
assert result.exit_code == 0
|
|
240
|
+
assert "Type" in result.output
|
|
241
|
+
assert "Title" in result.output
|
|
242
|
+
assert "Description" in result.output
|
|
243
|
+
assert "ID" in result.output
|
|
244
|
+
assert "Orders" in result.output
|
|
245
|
+
assert "Customer orders." in result.output
|
|
246
|
+
assert "tables/orders" in result.output
|
|
247
|
+
assert "okf read" in result.output
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def test_list_falls_back_to_stem_for_missing_title(tmp_path: Path):
|
|
251
|
+
d = tmp_path / "bundle"
|
|
252
|
+
d.mkdir()
|
|
253
|
+
_write(
|
|
254
|
+
d,
|
|
255
|
+
{
|
|
256
|
+
"tables/bad.md": (
|
|
257
|
+
"---\n"
|
|
258
|
+
"type: tables\n"
|
|
259
|
+
"---\n\n"
|
|
260
|
+
"Body."
|
|
261
|
+
),
|
|
262
|
+
},
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
result = runner.invoke(app, ["list", str(d)])
|
|
266
|
+
assert result.exit_code == 0
|
|
267
|
+
assert "bad" in result.output
|
|
268
|
+
|
|
269
|
+
|
|
213
270
|
# ---------------------------------------------------------------------------
|
|
214
271
|
# read — exit codes & error messages
|
|
215
272
|
# ---------------------------------------------------------------------------
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"""okf list command."""
|
|
2
|
-
|
|
3
|
-
import typer
|
|
4
|
-
|
|
5
|
-
from okf import api
|
|
6
|
-
from okf.core import console, err_console
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def cmd_list(
|
|
10
|
-
directory: str = typer.Argument(..., help="Directory of the OKF bundle"),
|
|
11
|
-
) -> None:
|
|
12
|
-
"""List all concept IDs in an OKF bundle."""
|
|
13
|
-
try:
|
|
14
|
-
cids = api.list_concepts(directory)
|
|
15
|
-
except (ValueError, NotADirectoryError) as e:
|
|
16
|
-
err_console.print(f"Error: {e}", style="red")
|
|
17
|
-
raise typer.Exit(code=1)
|
|
18
|
-
|
|
19
|
-
if not cids:
|
|
20
|
-
err_console.print("No concepts found", style="yellow")
|
|
21
|
-
raise typer.Exit(code=1)
|
|
22
|
-
|
|
23
|
-
for cid in cids:
|
|
24
|
-
console.print(cid, style="cyan")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|