mustmatch 0.0.1__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,235 @@
1
+ Metadata-Version: 2.4
2
+ Name: mustmatch
3
+ Version: 0.0.1
4
+ Summary: Validate CLI and Python projects
5
+ Author-email: Ian Maurer <ian@genomoncology.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/botassembly/mustmatch
8
+ Project-URL: Repository, https://github.com/botassembly/mustmatch
9
+ Keywords: testing,documentation,cli,assertions
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Testing
20
+ Classifier: Topic :: Documentation
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: mistune>=3.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.0; extra == "dev"
26
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
27
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
28
+
29
+ # mustmatch
30
+
31
+ **Assert CLI output. Test your documentation.**
32
+
33
+ ```bash
34
+ # Verify command output
35
+ echo "hello" | mustmatch "hello"
36
+
37
+ # Test for substrings
38
+ ls -la | mustmatch like "README"
39
+
40
+ # JSON comparison (field order doesn't matter)
41
+ echo '{"status":"ok","count":42}' | mustmatch like '{"status":"ok"}'
42
+
43
+ # Regex patterns
44
+ date +%Y-%m-%d | mustmatch '/^\d{4}-\d{2}-\d{2}$/'
45
+
46
+ # Assert errors DON'T appear
47
+ echo "success" | mustmatch not like "error"
48
+ ```
49
+
50
+ ## Install
51
+
52
+ ```
53
+ pip install mustmatch
54
+ ```
55
+
56
+ ## Why mustmatch?
57
+
58
+ Your documentation has examples. But do they work?
59
+
60
+ ```bash
61
+ # This example in your README:
62
+ echo "hello" | mustmatch "hello"
63
+
64
+ # Will it work tomorrow? Next week? After refactoring?
65
+ # With mustmatch, your docs are tests. If docs pass, examples work.
66
+ ```
67
+
68
+ ## Quick Start
69
+
70
+ ### 1. Pipe and Match
71
+
72
+ ```bash
73
+ echo "hello" | mustmatch "hello" # ✓ Exit 0
74
+ echo "hello world" | mustmatch like "world" # ✓ Contains
75
+ echo "success" | mustmatch not like "error" # ✓ Negation
76
+ ```
77
+
78
+ ### 2. Auto-Detection
79
+
80
+ mustmatch figures out what you want:
81
+
82
+ ```bash
83
+ # String comparison
84
+ echo "hello" | mustmatch "hello"
85
+
86
+ # Regex (from /slashes/)
87
+ date +%Y-%m-%d | mustmatch '/^\d{4}-\d{2}-\d{2}$/'
88
+
89
+ # JSON (from {braces})
90
+ echo '{"a":1,"b":2}' | mustmatch '{"a":1,"b":2}'
91
+ ```
92
+
93
+ ### 3. JSON Intelligence
94
+
95
+ ```bash
96
+ # Field order doesn't matter
97
+ echo '{"b":2,"a":1}' | mustmatch '{"a":1,"b":2}'
98
+
99
+ # Subset matching
100
+ echo '{"status":"ok","count":42}' | mustmatch like '{"status":"ok"}'
101
+ ```
102
+
103
+ ## Comparison Modes
104
+
105
+ ### Exact Match
106
+
107
+ ```bash
108
+ echo "hello" | mustmatch "hello"
109
+ ```
110
+
111
+ ### Contains (`like`)
112
+
113
+ ```bash
114
+ echo "hello world" | mustmatch like "world"
115
+ ls -la | mustmatch like "README"
116
+ ```
117
+
118
+ ### Negation (`not`)
119
+
120
+ ```bash
121
+ echo "success" | mustmatch not "error"
122
+ echo "success" | mustmatch not like "error"
123
+ ```
124
+
125
+ ### Regex (`/pattern/`)
126
+
127
+ ```bash
128
+ date +%Y-%m-%d | mustmatch '/^\d{4}-\d{2}-\d{2}$/'
129
+ echo "v1.2.3" | mustmatch '/^v\d+\.\d+\.\d+$/'
130
+ ```
131
+
132
+ ### JSON (semantic)
133
+
134
+ ```bash
135
+ # Field order doesn't matter
136
+ echo '{"b":2,"a":1}' | mustmatch '{"a":1,"b":2}'
137
+
138
+ # Subset matching
139
+ echo '{"status":"ok","count":42,"time":"2024-01-01"}' | \
140
+ mustmatch like '{"status":"ok"}'
141
+ ```
142
+
143
+ ## Text Normalization
144
+
145
+ mustmatch automatically cleans output:
146
+
147
+ ```bash
148
+ # ANSI codes stripped
149
+ ls --color=always | mustmatch like "README"
150
+
151
+ # Whitespace trimmed
152
+ echo " hello " | mustmatch "hello"
153
+
154
+ # Newlines normalized
155
+ printf "hello\r\n" | mustmatch "hello"
156
+ ```
157
+
158
+ ## Exit Codes
159
+
160
+ ```bash
161
+ echo "ok" | mustmatch "ok" # Exit 0 (match)
162
+ echo "ok" | mustmatch "fail" || echo "no match" # Exit 1
163
+
164
+ # Use in scripts
165
+ if echo "ready" | mustmatch "ready"; then
166
+ echo "Proceeding..."
167
+ fi
168
+ ```
169
+
170
+ ## Use Cases
171
+
172
+ ### Keep Documentation Up-to-Date
173
+
174
+ Every example in your docs becomes a test. If the example breaks, CI fails.
175
+
176
+ ### DevOps Scripts
177
+
178
+ Verify service health in deployment scripts.
179
+
180
+ ### API Testing
181
+
182
+ Test JSON API responses with semantic comparison.
183
+
184
+ ## CLI Reference
185
+
186
+ ```
187
+ Usage:
188
+ command | mustmatch [not] [like] EXPECTED
189
+
190
+ Options:
191
+ -i, --ignore-case Case-insensitive
192
+ -q, --quiet Suppress output
193
+ --version Show version
194
+ -h, --help Show help
195
+
196
+ Exit codes:
197
+ 0 Match succeeded
198
+ 1 Match failed
199
+ 2 Invalid arguments
200
+ ```
201
+
202
+ ## Examples
203
+
204
+ ```bash
205
+ # Exact match
206
+ echo "hello" | mustmatch "hello"
207
+
208
+ # Case insensitive
209
+ echo "HELLO" | mustmatch -i "hello"
210
+
211
+ # Contains
212
+ echo "hello world" | mustmatch like "world"
213
+
214
+ # Negation
215
+ echo "success" | mustmatch not like "error"
216
+
217
+ # Regex
218
+ date +%Y-%m-%d | mustmatch '/^\d{4}-\d{2}-\d{2}$/'
219
+
220
+ # JSON
221
+ echo '{"a":1,"b":2}' | mustmatch '{"a":1,"b":2}'
222
+
223
+ # JSON subset
224
+ echo '{"status":"ok","count":42}' | mustmatch like '{"status":"ok"}'
225
+
226
+ # Check help output
227
+ mustmatch --help | mustmatch like "Usage:"
228
+
229
+ # Verify version
230
+ mustmatch --version | mustmatch like "mustmatch"
231
+ ```
232
+
233
+ ## License
234
+
235
+ MIT
@@ -0,0 +1,207 @@
1
+ # mustmatch
2
+
3
+ **Assert CLI output. Test your documentation.**
4
+
5
+ ```bash
6
+ # Verify command output
7
+ echo "hello" | mustmatch "hello"
8
+
9
+ # Test for substrings
10
+ ls -la | mustmatch like "README"
11
+
12
+ # JSON comparison (field order doesn't matter)
13
+ echo '{"status":"ok","count":42}' | mustmatch like '{"status":"ok"}'
14
+
15
+ # Regex patterns
16
+ date +%Y-%m-%d | mustmatch '/^\d{4}-\d{2}-\d{2}$/'
17
+
18
+ # Assert errors DON'T appear
19
+ echo "success" | mustmatch not like "error"
20
+ ```
21
+
22
+ ## Install
23
+
24
+ ```
25
+ pip install mustmatch
26
+ ```
27
+
28
+ ## Why mustmatch?
29
+
30
+ Your documentation has examples. But do they work?
31
+
32
+ ```bash
33
+ # This example in your README:
34
+ echo "hello" | mustmatch "hello"
35
+
36
+ # Will it work tomorrow? Next week? After refactoring?
37
+ # With mustmatch, your docs are tests. If docs pass, examples work.
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ### 1. Pipe and Match
43
+
44
+ ```bash
45
+ echo "hello" | mustmatch "hello" # ✓ Exit 0
46
+ echo "hello world" | mustmatch like "world" # ✓ Contains
47
+ echo "success" | mustmatch not like "error" # ✓ Negation
48
+ ```
49
+
50
+ ### 2. Auto-Detection
51
+
52
+ mustmatch figures out what you want:
53
+
54
+ ```bash
55
+ # String comparison
56
+ echo "hello" | mustmatch "hello"
57
+
58
+ # Regex (from /slashes/)
59
+ date +%Y-%m-%d | mustmatch '/^\d{4}-\d{2}-\d{2}$/'
60
+
61
+ # JSON (from {braces})
62
+ echo '{"a":1,"b":2}' | mustmatch '{"a":1,"b":2}'
63
+ ```
64
+
65
+ ### 3. JSON Intelligence
66
+
67
+ ```bash
68
+ # Field order doesn't matter
69
+ echo '{"b":2,"a":1}' | mustmatch '{"a":1,"b":2}'
70
+
71
+ # Subset matching
72
+ echo '{"status":"ok","count":42}' | mustmatch like '{"status":"ok"}'
73
+ ```
74
+
75
+ ## Comparison Modes
76
+
77
+ ### Exact Match
78
+
79
+ ```bash
80
+ echo "hello" | mustmatch "hello"
81
+ ```
82
+
83
+ ### Contains (`like`)
84
+
85
+ ```bash
86
+ echo "hello world" | mustmatch like "world"
87
+ ls -la | mustmatch like "README"
88
+ ```
89
+
90
+ ### Negation (`not`)
91
+
92
+ ```bash
93
+ echo "success" | mustmatch not "error"
94
+ echo "success" | mustmatch not like "error"
95
+ ```
96
+
97
+ ### Regex (`/pattern/`)
98
+
99
+ ```bash
100
+ date +%Y-%m-%d | mustmatch '/^\d{4}-\d{2}-\d{2}$/'
101
+ echo "v1.2.3" | mustmatch '/^v\d+\.\d+\.\d+$/'
102
+ ```
103
+
104
+ ### JSON (semantic)
105
+
106
+ ```bash
107
+ # Field order doesn't matter
108
+ echo '{"b":2,"a":1}' | mustmatch '{"a":1,"b":2}'
109
+
110
+ # Subset matching
111
+ echo '{"status":"ok","count":42,"time":"2024-01-01"}' | \
112
+ mustmatch like '{"status":"ok"}'
113
+ ```
114
+
115
+ ## Text Normalization
116
+
117
+ mustmatch automatically cleans output:
118
+
119
+ ```bash
120
+ # ANSI codes stripped
121
+ ls --color=always | mustmatch like "README"
122
+
123
+ # Whitespace trimmed
124
+ echo " hello " | mustmatch "hello"
125
+
126
+ # Newlines normalized
127
+ printf "hello\r\n" | mustmatch "hello"
128
+ ```
129
+
130
+ ## Exit Codes
131
+
132
+ ```bash
133
+ echo "ok" | mustmatch "ok" # Exit 0 (match)
134
+ echo "ok" | mustmatch "fail" || echo "no match" # Exit 1
135
+
136
+ # Use in scripts
137
+ if echo "ready" | mustmatch "ready"; then
138
+ echo "Proceeding..."
139
+ fi
140
+ ```
141
+
142
+ ## Use Cases
143
+
144
+ ### Keep Documentation Up-to-Date
145
+
146
+ Every example in your docs becomes a test. If the example breaks, CI fails.
147
+
148
+ ### DevOps Scripts
149
+
150
+ Verify service health in deployment scripts.
151
+
152
+ ### API Testing
153
+
154
+ Test JSON API responses with semantic comparison.
155
+
156
+ ## CLI Reference
157
+
158
+ ```
159
+ Usage:
160
+ command | mustmatch [not] [like] EXPECTED
161
+
162
+ Options:
163
+ -i, --ignore-case Case-insensitive
164
+ -q, --quiet Suppress output
165
+ --version Show version
166
+ -h, --help Show help
167
+
168
+ Exit codes:
169
+ 0 Match succeeded
170
+ 1 Match failed
171
+ 2 Invalid arguments
172
+ ```
173
+
174
+ ## Examples
175
+
176
+ ```bash
177
+ # Exact match
178
+ echo "hello" | mustmatch "hello"
179
+
180
+ # Case insensitive
181
+ echo "HELLO" | mustmatch -i "hello"
182
+
183
+ # Contains
184
+ echo "hello world" | mustmatch like "world"
185
+
186
+ # Negation
187
+ echo "success" | mustmatch not like "error"
188
+
189
+ # Regex
190
+ date +%Y-%m-%d | mustmatch '/^\d{4}-\d{2}-\d{2}$/'
191
+
192
+ # JSON
193
+ echo '{"a":1,"b":2}' | mustmatch '{"a":1,"b":2}'
194
+
195
+ # JSON subset
196
+ echo '{"status":"ok","count":42}' | mustmatch like '{"status":"ok"}'
197
+
198
+ # Check help output
199
+ mustmatch --help | mustmatch like "Usage:"
200
+
201
+ # Verify version
202
+ mustmatch --version | mustmatch like "mustmatch"
203
+ ```
204
+
205
+ ## License
206
+
207
+ MIT
@@ -0,0 +1,83 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "mustmatch"
7
+ version = "0.0.1"
8
+ description = "Validate CLI and Python projects"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "Ian Maurer", email = "ian@genomoncology.com"}
14
+ ]
15
+ keywords = ["testing", "documentation", "cli", "assertions"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Topic :: Software Development :: Testing",
27
+ "Topic :: Documentation",
28
+ ]
29
+ dependencies = [
30
+ "mistune>=3.0",
31
+ ]
32
+
33
+ [project.urls]
34
+ Homepage = "https://github.com/botassembly/mustmatch"
35
+ Repository = "https://github.com/botassembly/mustmatch"
36
+
37
+ [project.scripts]
38
+ mustmatch = "mustmatch.cli:cli"
39
+
40
+ [project.entry-points."pytest11"]
41
+ mustmatch = "mustmatch.pytest_plugin"
42
+
43
+ [project.optional-dependencies]
44
+ dev = [
45
+ "pytest>=7.0",
46
+ "pytest-cov>=4.0",
47
+ "ruff>=0.1.0",
48
+ ]
49
+
50
+ [tool.setuptools.packages.find]
51
+ where = ["src"]
52
+
53
+ [tool.pytest.ini_options]
54
+ testpaths = ["docs"]
55
+ pythonpath = ["src"]
56
+ python_files = []
57
+ python_classes = []
58
+ python_functions = []
59
+
60
+ [tool.ruff]
61
+ line-length = 88
62
+ target-version = "py310"
63
+
64
+ [tool.ruff.lint]
65
+ select = ["E", "F", "I", "W"]
66
+
67
+ [tool.coverage.run]
68
+ source = ["src/mustmatch"]
69
+ branch = true
70
+ parallel = true
71
+ omit = [
72
+ "src/mustmatch/__main__.py",
73
+ "src/mustmatch/version.py",
74
+ "src/mustmatch/pytest_plugin.py",
75
+ "src/mustmatch/cli.py",
76
+ ]
77
+
78
+ [tool.coverage.report]
79
+ fail_under = 45
80
+ exclude_lines = [
81
+ "pragma: no cover",
82
+ "if __name__ == .__main__.:",
83
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,13 @@
1
+ """
2
+ mustmatch: CLI output assertion tool for documentation testing.
3
+
4
+ Public API:
5
+ - CLI: `mustmatch` command (see cli.py)
6
+ - pytest plugin: auto-loaded via entry point (see pytest_plugin.py)
7
+
8
+ All other functionality is internal.
9
+ """
10
+
11
+ from .version import __version__
12
+
13
+ __all__ = ["__version__"]
@@ -0,0 +1,6 @@
1
+ """Allow running as python -m mustmatch."""
2
+
3
+ from mustmatch.cli import cli
4
+
5
+ if __name__ == "__main__":
6
+ cli()