worklog-opsdevnz 0.1.0__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.
@@ -0,0 +1,90 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity
16
+ exercising permissions granted by this License.
17
+
18
+ "Source" form shall mean the preferred form for making modifications,
19
+ including but not limited to software source code, documentation
20
+ source, and configuration files.
21
+
22
+ "Object" form shall mean any form resulting from mechanical
23
+ transformation or translation of a Source form, including but
24
+ not limited to compiled object code, generated documentation,
25
+ and conversions to other media types.
26
+
27
+ "Work" shall mean the work of authorship, whether in Source or
28
+ Object form, made available under the License, as indicated by a
29
+ copyright notice that is included in or attached to the work
30
+ (an example is provided in the Appendix below).
31
+
32
+ "Derivative Works" shall mean any work, whether in Source or Object
33
+ form, that is based on (or derived from) the Work and for which the
34
+ editorial revisions, annotations, elaborations, or other modifications
35
+ represent, as a whole, an original work of authorship. For the purposes
36
+ of this License, Derivative Works shall not include works that remain
37
+ separable from, or merely link (or bind by name) to the interfaces of,
38
+ the Work and Derivative Works thereof.
39
+
40
+ "Contribution" shall mean any work of authorship, including
41
+ the original version of the Work and any modifications or additions
42
+ to that Work or Derivative Works thereof, that is intentionally
43
+ submitted to Licensor for inclusion in the Work by the copyright owner
44
+ or by an individual or Legal Entity authorized to submit on behalf of
45
+ the copyright owner.
46
+
47
+ "Contributor" shall mean Licensor and any individual or Legal Entity
48
+ on behalf of whom a Contribution has been received by Licensor and
49
+ subsequently incorporated within the Work.
50
+
51
+ 2. Grant of Copyright License. Subject to the terms and conditions of
52
+ this License, each Contributor hereby grants to You a perpetual,
53
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
54
+ copyright license to reproduce, prepare Derivative Works of,
55
+ publicly display, publicly perform, sublicense, and distribute the
56
+ Work and such Derivative Works in Source or Object form.
57
+
58
+ 3. Grant of Patent License. Subject to the terms and conditions of
59
+ this License, each Contributor hereby grants to You a perpetual,
60
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
61
+ (except as stated in this section) patent license to make, have made,
62
+ use, offer to sell, sell, import, and otherwise transfer the Work,
63
+ where such license applies only to those patent claims licensable
64
+ by such Contributor that are necessarily infringed by their
65
+ Contribution(s) alone or by combination of their Contribution(s)
66
+ with the Work to which such Contribution(s) was submitted.
67
+
68
+ 4. Redistribution. You may reproduce and distribute copies of the
69
+ Work or Derivative Works thereof in any medium, with or without
70
+ modifications, and in Source or Object form, provided that You
71
+ meet the following conditions:
72
+
73
+ (a) You must give any other recipients of the Work or
74
+ Derivative Works a copy of this License; and
75
+
76
+ (b) You must cause any modified files to carry prominent notices
77
+ stating that You changed the files; and
78
+
79
+ (c) You must retain, in the Source form of any Derivative Works
80
+ that You distribute, all copyright, patent, trademark, and
81
+ attribution notices from the Source form of the Work,
82
+ excluding those notices that do not pertain to any part of
83
+ the Derivative Works; and
84
+
85
+ (d) If the Work includes a "NOTICE" text file as part of its
86
+ distribution, then any Derivative Works that You distribute must
87
+ include a readable copy of the attribution notices contained
88
+ within such NOTICE file.
89
+
90
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.4
2
+ Name: worklog-opsdevnz
3
+ Version: 0.1.0
4
+ Summary: Configurable worklog management CLI for dated development logs
5
+ Author-email: "OpsDev.nz Collective" <john@opsdev.nz>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/startmeup-nz/worklog-opsdevnz
8
+ Project-URL: Documentation, https://opsdev.nz/modules/worklog-opsdevnz
9
+ Project-URL: Repository, https://github.com/startmeup-nz/worklog-opsdevnz.git
10
+ Project-URL: Bug Tracker, https://github.com/startmeup-nz/worklog-opsdevnz/issues
11
+ Keywords: worklog,documentation,daily-log,cli,markdown
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Software Development :: Documentation
20
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
21
+ Requires-Python: >=3.12
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: click>=8.0
25
+ Requires-Dist: pyyaml>=6.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0; extra == "dev"
28
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
29
+ Requires-Dist: pytest-mock>=3.10; extra == "dev"
30
+ Requires-Dist: ruff>=0.4; extra == "dev"
31
+ Requires-Dist: mypy>=1.0; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ # WorkLog OpsDev.NZ
35
+
36
+ **Status:** Development — see pyproject.toml for version
37
+
38
+ Configurable CLI tool for creating and managing dated development worklogs.
39
+ Generates Markdown entries with YAML frontmatter from per-project templates.
40
+
41
+ ## Problem
42
+
43
+ Across multiple projects we kept reinventing the same pattern: a script that
44
+ creates a dated Markdown file from a template, with frontmatter for date,
45
+ author, tags, and draft status. Each implementation had slightly different
46
+ directory structures, section headers, and filenames. The core concept was
47
+ always the same.
48
+
49
+ ## Solution
50
+
51
+ `worklog-opsdevnz` formalises this pattern into a single published module:
52
+
53
+ - **Per-project config** — `worklog.toml` controls directory structure, sections,
54
+ author, tags, and filename patterns
55
+ - **Three structure modes** — `flat`, `year`, or `year-month` directory layouts
56
+ - **YAML frontmatter** — date, title, author, tags, draft status
57
+ - **Configurable sections** — each project defines its own section headers
58
+ - **Editor integration** — opens new entries in `$VISUAL` / `$EDITOR`
59
+ - **List existing entries** — browse worklogs with `--list`
60
+
61
+ ## Quick Start
62
+
63
+ ```bash
64
+ # Create today's worklog
65
+ worklog-opsdevnz
66
+
67
+ # Create yesterday's worklog
68
+ worklog-opsdevnz --previous
69
+
70
+ # Override the editor for this run
71
+ worklog-opsdevnz --editor nvim
72
+ ```
73
+
74
+ ## Configuration
75
+
76
+ Each project gets a `worklog.toml` at its root:
77
+
78
+ ```toml
79
+ worklog_dir = "docs/worklog"
80
+ structure = "year" # "flat", "year", or "year-month"
81
+ author = "Your Name"
82
+ default_tags = ["worklog", "log"]
83
+
84
+ [[sections]]
85
+ title = "Focus for Today"
86
+
87
+ [[sections]]
88
+ title = "Completed"
89
+
90
+ [[sections]]
91
+ title = "Notes"
92
+
93
+ [[sections]]
94
+ title = "Next"
95
+ ```
96
+
97
+ ## Scope
98
+
99
+ **WorkLog DOES:**
100
+ - Create dated Markdown worklog entries with YAML frontmatter
101
+ - Per-project configuration via `worklog.toml`
102
+ - Open entries in configured editor (`$VISUAL` / `$EDITOR`)
103
+ - Three directory structure modes: flat, year, year-month
104
+
105
+ **WorkLog DOES NOT (out of scope for 0.0.2):**
106
+ - Zensical blog integration (see design doc)
107
+ - Auto-generated index pages
108
+ - Retro template support (planned for 0.1.0)
109
+ - Time tracking / timesheet aggregation
110
+ - `list`, `init`, or `create` subcommands (planned for 0.1.0)
111
+
112
+ ## Requirements
113
+
114
+ - Python 3.12+
115
+ - See [pyproject.toml](pyproject.toml) for full dependencies
116
+
117
+ ## Related
118
+
119
+ - [Functional Requirements](docs/specs/README.md)
120
+ - [Design Decisions](docs/design/README.md)
121
+ - [User Stories](docs/stories/README.md)
122
+
123
+ ---
124
+
125
+ **Last Updated:** 2026-05-23
126
+ **Status:** Development (migrated to module template)
127
+ **Maintainer:** OpsDev.nz Collective
@@ -0,0 +1,94 @@
1
+ # WorkLog OpsDev.NZ
2
+
3
+ **Status:** Development — see pyproject.toml for version
4
+
5
+ Configurable CLI tool for creating and managing dated development worklogs.
6
+ Generates Markdown entries with YAML frontmatter from per-project templates.
7
+
8
+ ## Problem
9
+
10
+ Across multiple projects we kept reinventing the same pattern: a script that
11
+ creates a dated Markdown file from a template, with frontmatter for date,
12
+ author, tags, and draft status. Each implementation had slightly different
13
+ directory structures, section headers, and filenames. The core concept was
14
+ always the same.
15
+
16
+ ## Solution
17
+
18
+ `worklog-opsdevnz` formalises this pattern into a single published module:
19
+
20
+ - **Per-project config** — `worklog.toml` controls directory structure, sections,
21
+ author, tags, and filename patterns
22
+ - **Three structure modes** — `flat`, `year`, or `year-month` directory layouts
23
+ - **YAML frontmatter** — date, title, author, tags, draft status
24
+ - **Configurable sections** — each project defines its own section headers
25
+ - **Editor integration** — opens new entries in `$VISUAL` / `$EDITOR`
26
+ - **List existing entries** — browse worklogs with `--list`
27
+
28
+ ## Quick Start
29
+
30
+ ```bash
31
+ # Create today's worklog
32
+ worklog-opsdevnz
33
+
34
+ # Create yesterday's worklog
35
+ worklog-opsdevnz --previous
36
+
37
+ # Override the editor for this run
38
+ worklog-opsdevnz --editor nvim
39
+ ```
40
+
41
+ ## Configuration
42
+
43
+ Each project gets a `worklog.toml` at its root:
44
+
45
+ ```toml
46
+ worklog_dir = "docs/worklog"
47
+ structure = "year" # "flat", "year", or "year-month"
48
+ author = "Your Name"
49
+ default_tags = ["worklog", "log"]
50
+
51
+ [[sections]]
52
+ title = "Focus for Today"
53
+
54
+ [[sections]]
55
+ title = "Completed"
56
+
57
+ [[sections]]
58
+ title = "Notes"
59
+
60
+ [[sections]]
61
+ title = "Next"
62
+ ```
63
+
64
+ ## Scope
65
+
66
+ **WorkLog DOES:**
67
+ - Create dated Markdown worklog entries with YAML frontmatter
68
+ - Per-project configuration via `worklog.toml`
69
+ - Open entries in configured editor (`$VISUAL` / `$EDITOR`)
70
+ - Three directory structure modes: flat, year, year-month
71
+
72
+ **WorkLog DOES NOT (out of scope for 0.0.2):**
73
+ - Zensical blog integration (see design doc)
74
+ - Auto-generated index pages
75
+ - Retro template support (planned for 0.1.0)
76
+ - Time tracking / timesheet aggregation
77
+ - `list`, `init`, or `create` subcommands (planned for 0.1.0)
78
+
79
+ ## Requirements
80
+
81
+ - Python 3.12+
82
+ - See [pyproject.toml](pyproject.toml) for full dependencies
83
+
84
+ ## Related
85
+
86
+ - [Functional Requirements](docs/specs/README.md)
87
+ - [Design Decisions](docs/design/README.md)
88
+ - [User Stories](docs/stories/README.md)
89
+
90
+ ---
91
+
92
+ **Last Updated:** 2026-05-23
93
+ **Status:** Development (migrated to module template)
94
+ **Maintainer:** OpsDev.nz Collective
@@ -0,0 +1,70 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "worklog-opsdevnz"
7
+ version = "0.1.0"
8
+ description = "Configurable worklog management CLI for dated development logs"
9
+ readme = "README.md"
10
+ license = {text = "Apache-2.0"}
11
+ authors = [
12
+ {name = "OpsDev.nz Collective", email = "john@opsdev.nz"}
13
+ ]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: Apache Software License",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Programming Language :: Python :: 3.14",
22
+ "Topic :: Software Development :: Documentation",
23
+ "Topic :: Text Processing :: Markup :: Markdown"
24
+ ]
25
+ keywords = ["worklog", "documentation", "daily-log", "cli", "markdown"]
26
+ requires-python = ">=3.12"
27
+
28
+ dependencies = [
29
+ "click>=8.0",
30
+ "pyyaml>=6.0",
31
+ ]
32
+
33
+ [project.optional-dependencies]
34
+ dev = [
35
+ "pytest>=7.0",
36
+ "pytest-cov>=4.0",
37
+ "pytest-mock>=3.10",
38
+ "ruff>=0.4",
39
+ "mypy>=1.0",
40
+ ]
41
+
42
+ [project.urls]
43
+ Homepage = "https://github.com/startmeup-nz/worklog-opsdevnz"
44
+ Documentation = "https://opsdev.nz/modules/worklog-opsdevnz"
45
+ Repository = "https://github.com/startmeup-nz/worklog-opsdevnz.git"
46
+ "Bug Tracker" = "https://github.com/startmeup-nz/worklog-opsdevnz/issues"
47
+
48
+ [project.scripts]
49
+ worklog-opsdevnz = "worklog_opsdevnz.cli:main"
50
+
51
+ [tool.setuptools.packages.find]
52
+ where = ["src"]
53
+ exclude = ["tests*", ".venv*"]
54
+
55
+ [tool.setuptools.package-data]
56
+ worklog_opsdevnz = ["templates/**/*"]
57
+
58
+ [tool.pytest.ini_options]
59
+ testpaths = ["tests"]
60
+ python_files = ["test_*.py"]
61
+ addopts = "-v --cov=src/worklog_opsdevnz --cov-report=term-missing"
62
+
63
+ [tool.ruff]
64
+ line-length = 88
65
+ target-version = "py312"
66
+
67
+ [tool.mypy]
68
+ python_version = "3.12"
69
+ warn_return_any = true
70
+ disallow_untyped_defs = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,8 @@
1
+ """worklog-opsdevnz — Configurable worklog management CLI."""
2
+
3
+ from importlib import metadata
4
+
5
+ try:
6
+ __version__ = metadata.version("worklog-opsdevnz")
7
+ except metadata.PackageNotFoundError:
8
+ __version__ = "0.0.0+local"
@@ -0,0 +1,68 @@
1
+ """CLI entry point for worklog-opsdevnz."""
2
+
3
+ import shutil
4
+ import subprocess
5
+ from datetime import date
6
+ from pathlib import Path
7
+
8
+ import click
9
+
10
+ from worklog_opsdevnz import __version__
11
+ from worklog_opsdevnz.config import get_config
12
+ from worklog_opsdevnz.paths import resolve_path
13
+ from worklog_opsdevnz.template import generate_content
14
+
15
+
16
+ @click.command()
17
+ @click.version_option(version=__version__, prog_name="worklog-opsdevnz")
18
+ @click.option(
19
+ "-e",
20
+ "--editor",
21
+ default=None,
22
+ help="Override the editor command (default: $VISUAL or $EDITOR).",
23
+ )
24
+ def main(editor: str | None) -> None:
25
+ """Create or open today's worklog entry."""
26
+ entry_date = date.today()
27
+
28
+ config = get_config()
29
+ target = resolve_path(config, entry_date)
30
+ target.parent.mkdir(parents=True, exist_ok=True)
31
+
32
+ if target.exists():
33
+ print(f"Opening existing worklog: {target}")
34
+ else:
35
+ content = generate_content(config, entry_date.isoformat())
36
+ target.write_text(content)
37
+ print(f"Created: {target}")
38
+
39
+ _open_editor(target, editor)
40
+
41
+
42
+ def _open_editor(path: str | Path, override: str | None = None) -> None:
43
+ """Open the file in the configured editor, or print the path."""
44
+ editor = _resolve_editor(override)
45
+ if editor:
46
+ editor_cmd = shutil.which(editor)
47
+ if editor_cmd:
48
+ # fmt: off
49
+ subprocess.run([editor_cmd, str(path)])
50
+ # fmt: on
51
+ else:
52
+ print(f"Editor '{editor}' not found. Path: {path}")
53
+ else:
54
+ print(f"No editor configured. Path: {path}")
55
+
56
+
57
+ def _resolve_editor(override: str | None = None) -> str | None:
58
+ """Resolve editor from CLI override, $VISUAL, or $EDITOR."""
59
+ import os
60
+
61
+ for candidate in (override, os.environ.get("VISUAL"), os.environ.get("EDITOR")):
62
+ if candidate:
63
+ return candidate
64
+ return None
65
+
66
+
67
+ if __name__ == "__main__":
68
+ main()
@@ -0,0 +1,71 @@
1
+ """Configuration discovery and loading for worklog-opsdevnz."""
2
+
3
+ import os
4
+ import sys
5
+ import tomllib
6
+ from pathlib import Path
7
+ from typing import Any
8
+
9
+ DEFAULT_CONFIG: dict[str, Any] = {
10
+ "worklog_dir": "docs/worklog",
11
+ "structure": "year",
12
+ "suffix": "worklog",
13
+ "author": os.environ.get("USER", "unknown"),
14
+ "default_tags": ["internal", "log"],
15
+ "sections": [
16
+ {"title": "Focus for Today", "content": ""},
17
+ {"title": "Completed", "content": ""},
18
+ {"title": "Notes & Reflections", "content": ""},
19
+ {"title": "Related", "content": ""},
20
+ {"title": "Next", "content": ""},
21
+ ],
22
+ }
23
+
24
+
25
+ def find_config(start: Path | None = None) -> Path | None:
26
+ """Search for worklog.toml or worklog.yaml from start up to root."""
27
+ if start is None:
28
+ start = Path.cwd()
29
+ candidates = list(start.parents) + [start]
30
+ for candidate in candidates:
31
+ for name in ("worklog.toml", "worklog.yaml", "worklog.yml"):
32
+ path = candidate / name
33
+ if path.exists():
34
+ return path
35
+ return None
36
+
37
+
38
+ def load_config(path: Path) -> dict[str, Any]:
39
+ """Load config from TOML or YAML file."""
40
+ if path.suffix == ".toml":
41
+ with open(path, "rb") as f:
42
+ return tomllib.load(f)
43
+ else:
44
+ try:
45
+ import yaml # type: ignore[import-untyped]
46
+ except ImportError:
47
+ print("Error: PyYAML required for .yaml config", file=sys.stderr)
48
+ sys.exit(1)
49
+ with open(path) as f:
50
+ return yaml.safe_load(f) or {}
51
+
52
+
53
+ def merge_config(
54
+ file_config: dict[str, Any], defaults: dict[str, Any]
55
+ ) -> dict[str, Any]:
56
+ """Merge file config over defaults."""
57
+ merged = dict(defaults)
58
+ merged.update(file_config)
59
+ return merged
60
+
61
+
62
+ def get_config() -> dict[str, Any]:
63
+ """Discover and load config, falling back to defaults."""
64
+ config_path = find_config()
65
+ if config_path:
66
+ merged = merge_config(load_config(config_path), DEFAULT_CONFIG)
67
+ worklog_dir = merged["worklog_dir"]
68
+ if not Path(worklog_dir).is_absolute():
69
+ merged["worklog_dir"] = str(config_path.parent / worklog_dir)
70
+ return merged
71
+ return dict(DEFAULT_CONFIG)
@@ -0,0 +1,28 @@
1
+ """Path resolution for worklog files."""
2
+
3
+ from datetime import date
4
+ from pathlib import Path
5
+ from typing import Any
6
+
7
+
8
+ def resolve_path(
9
+ config: dict[str, Any],
10
+ entry_date: date,
11
+ ) -> Path:
12
+ """Compute the target file path based on config structure."""
13
+ base = Path(config.get("worklog_dir", "docs/worklog"))
14
+ structure = config.get("structure", "year")
15
+ suffix = config.get("suffix", "worklog")
16
+
17
+ if structure == "flat":
18
+ filename = f"{entry_date.isoformat()}-{suffix}.md"
19
+ return base / filename
20
+ elif structure == "year-month":
21
+ year = entry_date.strftime("%Y")
22
+ month = entry_date.strftime("%m")
23
+ filename = f"{entry_date.strftime('%d-%m-%Y')}-{suffix}.md"
24
+ return base / year / month / filename
25
+ else: # "year" (default)
26
+ year = entry_date.strftime("%Y")
27
+ filename = f"{entry_date.strftime('%d-%m-%Y')}-{suffix}.md"
28
+ return base / year / filename
@@ -0,0 +1,46 @@
1
+ """Frontmatter and body generation for worklog entries."""
2
+
3
+ from typing import Any
4
+
5
+
6
+ def generate_frontmatter(
7
+ config: dict[str, Any],
8
+ iso_date: str,
9
+ ) -> str:
10
+ """Generate YAML frontmatter."""
11
+ title = f"Work Log - {iso_date}"
12
+ tags = "\n".join(f" - {t}" for t in config.get("default_tags", []))
13
+ author = config.get("author", "unknown")
14
+
15
+ return f"""---
16
+ title: "{title}"
17
+ date: {iso_date}
18
+ author: {author}
19
+ tags:
20
+ {tags}
21
+ draft: false
22
+ ---
23
+ """
24
+
25
+
26
+ def generate_body(config: dict[str, Any]) -> str:
27
+ """Generate section headers from config."""
28
+ sections = config.get("sections", [])
29
+ lines = []
30
+ for section in sections:
31
+ title = section.get("title", "")
32
+ content = section.get("content", "")
33
+ lines.append(f"## {title}\n")
34
+ if content:
35
+ lines.append(f"{content}\n")
36
+ return "\n".join(lines)
37
+
38
+
39
+ def generate_content(
40
+ config: dict[str, Any],
41
+ iso_date: str,
42
+ ) -> str:
43
+ """Generate full worklog content."""
44
+ frontmatter = generate_frontmatter(config, iso_date)
45
+ body = generate_body(config)
46
+ return f"{frontmatter}\n{body}"
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.4
2
+ Name: worklog-opsdevnz
3
+ Version: 0.1.0
4
+ Summary: Configurable worklog management CLI for dated development logs
5
+ Author-email: "OpsDev.nz Collective" <john@opsdev.nz>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/startmeup-nz/worklog-opsdevnz
8
+ Project-URL: Documentation, https://opsdev.nz/modules/worklog-opsdevnz
9
+ Project-URL: Repository, https://github.com/startmeup-nz/worklog-opsdevnz.git
10
+ Project-URL: Bug Tracker, https://github.com/startmeup-nz/worklog-opsdevnz/issues
11
+ Keywords: worklog,documentation,daily-log,cli,markdown
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Software Development :: Documentation
20
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
21
+ Requires-Python: >=3.12
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: click>=8.0
25
+ Requires-Dist: pyyaml>=6.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0; extra == "dev"
28
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
29
+ Requires-Dist: pytest-mock>=3.10; extra == "dev"
30
+ Requires-Dist: ruff>=0.4; extra == "dev"
31
+ Requires-Dist: mypy>=1.0; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ # WorkLog OpsDev.NZ
35
+
36
+ **Status:** Development — see pyproject.toml for version
37
+
38
+ Configurable CLI tool for creating and managing dated development worklogs.
39
+ Generates Markdown entries with YAML frontmatter from per-project templates.
40
+
41
+ ## Problem
42
+
43
+ Across multiple projects we kept reinventing the same pattern: a script that
44
+ creates a dated Markdown file from a template, with frontmatter for date,
45
+ author, tags, and draft status. Each implementation had slightly different
46
+ directory structures, section headers, and filenames. The core concept was
47
+ always the same.
48
+
49
+ ## Solution
50
+
51
+ `worklog-opsdevnz` formalises this pattern into a single published module:
52
+
53
+ - **Per-project config** — `worklog.toml` controls directory structure, sections,
54
+ author, tags, and filename patterns
55
+ - **Three structure modes** — `flat`, `year`, or `year-month` directory layouts
56
+ - **YAML frontmatter** — date, title, author, tags, draft status
57
+ - **Configurable sections** — each project defines its own section headers
58
+ - **Editor integration** — opens new entries in `$VISUAL` / `$EDITOR`
59
+ - **List existing entries** — browse worklogs with `--list`
60
+
61
+ ## Quick Start
62
+
63
+ ```bash
64
+ # Create today's worklog
65
+ worklog-opsdevnz
66
+
67
+ # Create yesterday's worklog
68
+ worklog-opsdevnz --previous
69
+
70
+ # Override the editor for this run
71
+ worklog-opsdevnz --editor nvim
72
+ ```
73
+
74
+ ## Configuration
75
+
76
+ Each project gets a `worklog.toml` at its root:
77
+
78
+ ```toml
79
+ worklog_dir = "docs/worklog"
80
+ structure = "year" # "flat", "year", or "year-month"
81
+ author = "Your Name"
82
+ default_tags = ["worklog", "log"]
83
+
84
+ [[sections]]
85
+ title = "Focus for Today"
86
+
87
+ [[sections]]
88
+ title = "Completed"
89
+
90
+ [[sections]]
91
+ title = "Notes"
92
+
93
+ [[sections]]
94
+ title = "Next"
95
+ ```
96
+
97
+ ## Scope
98
+
99
+ **WorkLog DOES:**
100
+ - Create dated Markdown worklog entries with YAML frontmatter
101
+ - Per-project configuration via `worklog.toml`
102
+ - Open entries in configured editor (`$VISUAL` / `$EDITOR`)
103
+ - Three directory structure modes: flat, year, year-month
104
+
105
+ **WorkLog DOES NOT (out of scope for 0.0.2):**
106
+ - Zensical blog integration (see design doc)
107
+ - Auto-generated index pages
108
+ - Retro template support (planned for 0.1.0)
109
+ - Time tracking / timesheet aggregation
110
+ - `list`, `init`, or `create` subcommands (planned for 0.1.0)
111
+
112
+ ## Requirements
113
+
114
+ - Python 3.12+
115
+ - See [pyproject.toml](pyproject.toml) for full dependencies
116
+
117
+ ## Related
118
+
119
+ - [Functional Requirements](docs/specs/README.md)
120
+ - [Design Decisions](docs/design/README.md)
121
+ - [User Stories](docs/stories/README.md)
122
+
123
+ ---
124
+
125
+ **Last Updated:** 2026-05-23
126
+ **Status:** Development (migrated to module template)
127
+ **Maintainer:** OpsDev.nz Collective
@@ -0,0 +1,18 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/worklog_opsdevnz/__init__.py
5
+ src/worklog_opsdevnz/cli.py
6
+ src/worklog_opsdevnz/config.py
7
+ src/worklog_opsdevnz/paths.py
8
+ src/worklog_opsdevnz/template.py
9
+ src/worklog_opsdevnz.egg-info/PKG-INFO
10
+ src/worklog_opsdevnz.egg-info/SOURCES.txt
11
+ src/worklog_opsdevnz.egg-info/dependency_links.txt
12
+ src/worklog_opsdevnz.egg-info/entry_points.txt
13
+ src/worklog_opsdevnz.egg-info/requires.txt
14
+ src/worklog_opsdevnz.egg-info/top_level.txt
15
+ tests/test_cli.py
16
+ tests/test_config.py
17
+ tests/test_paths.py
18
+ tests/test_template.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ worklog-opsdevnz = worklog_opsdevnz.cli:main
@@ -0,0 +1,9 @@
1
+ click>=8.0
2
+ pyyaml>=6.0
3
+
4
+ [dev]
5
+ pytest>=7.0
6
+ pytest-cov>=4.0
7
+ pytest-mock>=3.10
8
+ ruff>=0.4
9
+ mypy>=1.0
@@ -0,0 +1 @@
1
+ worklog_opsdevnz
@@ -0,0 +1,49 @@
1
+ """Tests for CLI entry point."""
2
+
3
+ from datetime import date
4
+
5
+ from click.testing import CliRunner
6
+
7
+ from worklog_opsdevnz.cli import main
8
+
9
+
10
+ def test_main_creates_file(tmp_path, monkeypatch):
11
+ """Running with no args creates today's worklog in tmp_path."""
12
+ monkeypatch.chdir(tmp_path)
13
+ runner = CliRunner()
14
+ result = runner.invoke(main, [])
15
+ assert result.exit_code == 0
16
+ assert "Created" in result.output
17
+ expected_leaf = (
18
+ f"docs/worklog/{date.today().year}/{date.today():%d-%m-%Y}-worklog.md"
19
+ )
20
+ assert expected_leaf in result.output
21
+
22
+
23
+ def test_main_opens_existing(tmp_path, monkeypatch):
24
+ """Running again opens the existing file."""
25
+ monkeypatch.chdir(tmp_path)
26
+ runner = CliRunner()
27
+ runner.invoke(main, [])
28
+ result = runner.invoke(main, [])
29
+ assert result.exit_code == 0
30
+ assert "Opening existing" in result.output
31
+
32
+
33
+ def test_main_help():
34
+ """--help works."""
35
+ runner = CliRunner()
36
+ result = runner.invoke(main, ["--help"])
37
+ assert result.exit_code == 0
38
+ assert "--editor" in result.output
39
+
40
+
41
+ def test_main_version():
42
+ """--version prints the installed version."""
43
+ runner = CliRunner()
44
+ result = runner.invoke(main, ["--version"])
45
+ assert result.exit_code == 0
46
+ assert "worklog-opsdevnz, version" in result.output
47
+ # Extract and verify it's a non-empty version string
48
+ version_str = result.output.strip().split(", version ")[-1]
49
+ assert version_str
@@ -0,0 +1,69 @@
1
+ """Tests for config discovery and loading."""
2
+
3
+ from pathlib import Path
4
+
5
+ from worklog_opsdevnz.config import find_config, get_config, merge_config
6
+
7
+
8
+ def test_find_config_toml(tmp_path: Path, tmp_path_factory: Path):
9
+ """Search finds config in start dir; returns None from a path with no config above it."""
10
+ empty = tmp_path_factory.mktemp("empty")
11
+ assert find_config(start=empty) is None
12
+
13
+ (tmp_path / "worklog.toml").write_text('author = "test-user"')
14
+ found = find_config(start=tmp_path)
15
+ assert found is not None
16
+ assert found.name == "worklog.toml"
17
+
18
+
19
+ def test_find_config_walks_up(tmp_path: Path):
20
+ (tmp_path / "worklog.toml").write_text('author = "test-user"')
21
+ sub = tmp_path / "sub" / "deep"
22
+ sub.mkdir(parents=True)
23
+
24
+ found = find_config(start=sub)
25
+ assert found is not None
26
+ assert found.parent == tmp_path
27
+
28
+
29
+ def test_find_config_not_found(tmp_path: Path):
30
+ assert find_config(start=tmp_path) is None
31
+
32
+
33
+ def test_merge_config_overrides():
34
+ defaults = {"author": "unknown", "suffix": "worklog"}
35
+ file_cfg = {"author": "john"}
36
+ merged = merge_config(file_cfg, defaults)
37
+ assert merged["author"] == "john"
38
+ assert merged["suffix"] == "worklog"
39
+
40
+
41
+ def test_get_config_defaults(tmp_path: Path, monkeypatch):
42
+ monkeypatch.chdir(tmp_path)
43
+ config = get_config()
44
+ assert config["structure"] == "year"
45
+ assert config["suffix"] == "worklog"
46
+ assert config["worklog_dir"] == "docs/worklog"
47
+ assert len(config["sections"]) == 5
48
+
49
+
50
+ def test_get_config_from_file(tmp_path: Path, monkeypatch):
51
+ monkeypatch.chdir(tmp_path)
52
+ (tmp_path / "worklog.toml").write_text('author = "Test Author"\nstructure = "flat"')
53
+ config = get_config()
54
+ assert config["author"] == "Test Author"
55
+ assert config["structure"] == "flat"
56
+ assert config["suffix"] == "worklog" # default preserved
57
+ # worklog_dir defaults to "docs/worklog" and should be resolved to absolute
58
+ assert config["worklog_dir"] == str(tmp_path / "docs/worklog")
59
+
60
+
61
+ def test_get_config_worklog_dir_resolved_relative_to_config(tmp_path: Path, monkeypatch):
62
+ """worklog_dir is resolved against config file directory, not CWD."""
63
+ (tmp_path / "worklog.toml").write_text('worklog_dir = "my/logs"')
64
+ sub = tmp_path / "sub" / "deep"
65
+ sub.mkdir(parents=True)
66
+ monkeypatch.chdir(sub)
67
+
68
+ config = get_config()
69
+ assert config["worklog_dir"] == str(tmp_path / "my/logs")
@@ -0,0 +1,29 @@
1
+ """Tests for path resolution."""
2
+
3
+ from datetime import date
4
+
5
+ from worklog_opsdevnz.paths import resolve_path
6
+
7
+
8
+ def test_resolve_path_flat():
9
+ config = {"worklog_dir": "docs/worklog", "structure": "flat", "suffix": "worklog"}
10
+ path = resolve_path(config, date(2026, 5, 23))
11
+ assert str(path) == "docs/worklog/2026-05-23-worklog.md"
12
+
13
+
14
+ def test_resolve_path_year():
15
+ config = {"worklog_dir": "logs", "structure": "year", "suffix": "log"}
16
+ path = resolve_path(config, date(2026, 5, 23))
17
+ assert str(path) == "logs/2026/23-05-2026-log.md"
18
+
19
+
20
+ def test_resolve_path_year_month():
21
+ config = {"worklog_dir": "logs", "structure": "year-month", "suffix": "ops"}
22
+ path = resolve_path(config, date(2026, 5, 23))
23
+ assert str(path) == "logs/2026/05/23-05-2026-ops.md"
24
+
25
+
26
+ def test_resolve_path_custom_suffix():
27
+ config = {"structure": "year", "suffix": "retro"}
28
+ path = resolve_path(config, date(2026, 1, 1))
29
+ assert str(path).endswith("-retro.md")
@@ -0,0 +1,45 @@
1
+ """Tests for frontmatter and body generation."""
2
+
3
+ from worklog_opsdevnz.template import generate_frontmatter, generate_body, generate_content
4
+
5
+
6
+ def test_generate_frontmatter():
7
+ config = {
8
+ "author": "Test Author",
9
+ "default_tags": ["internal", "test"],
10
+ }
11
+ fm = generate_frontmatter(config, "2026-05-23")
12
+ assert "title: " in fm
13
+ assert "Work Log - 2026-05-23" in fm
14
+ assert "date: 2026-05-23" in fm
15
+ assert "author: Test Author" in fm
16
+ assert " - internal" in fm
17
+ assert " - test" in fm
18
+ assert "draft: false" in fm
19
+ assert fm.startswith("---")
20
+ assert fm.strip().endswith("---")
21
+
22
+
23
+ def test_generate_body_with_sections():
24
+ config = {
25
+ "sections": [
26
+ {"title": "Focus", "content": ""},
27
+ {"title": "Notes", "content": "some note"},
28
+ ]
29
+ }
30
+ body = generate_body(config)
31
+ assert "## Focus" in body
32
+ assert "## Notes" in body
33
+ assert "some note" in body
34
+
35
+
36
+ def test_generate_content_full():
37
+ config = {
38
+ "author": "opsdev",
39
+ "default_tags": ["log"],
40
+ "sections": [{"title": "Today", "content": ""}],
41
+ }
42
+ content = generate_content(config, "2026-05-23")
43
+ assert content.startswith("---")
44
+ assert "Work Log - 2026-05-23" in content
45
+ assert "## Today" in content