-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreview-python-cli-framework.html
More file actions
445 lines (394 loc) · 17.6 KB
/
preview-python-cli-framework.html
File metadata and controls
445 lines (394 loc) · 17.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
<!DOCTYPE html>
<html lang="en" data-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Preview Python CLI Framework — see the file structure, code samples, and documentation before you buy.">
<meta name="theme-color" content="#2563eb">
<title>Python CLI Framework — Preview | Python Developer Pro</title>
<link rel="icon" type="image/svg+xml" href="favicon.svg">
<link rel="stylesheet" href="style.css">
<style>
/* Preview page specific styles */
.preview-page { padding-top: calc(var(--header-height, 72px) + 2rem); padding-bottom: 4rem; }
.preview-back {
display: inline-flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 1.5rem;
color: var(--color-text-muted, #94a3b8);
font-size: 0.875rem;
text-decoration: none;
transition: color 0.2s;
}
.preview-back:hover { color: var(--color-primary, #3b82f6); }
.preview-header {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1.5rem;
padding-bottom: 1rem;
border-bottom: 1px solid var(--color-card-border, #334155);
}
.preview-header h1 { margin: 0; font-size: 1.75rem; }
.preview-header .price {
font-size: 1.75rem;
font-weight: 800;
color: var(--color-accent, #22d3ee);
}
.preview-desc {
color: var(--color-text-muted, #94a3b8);
margin-bottom: 1.5rem;
font-size: 1rem;
line-height: 1.6;
max-width: 80ch;
}
.preview-badges {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-bottom: 2rem;
}
.preview-badge {
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0.25rem 0.75rem;
border-radius: 9999px;
font-size: 0.75rem;
font-weight: 600;
border: 1px solid;
}
.preview-badge .dot {
width: 8px; height: 8px;
border-radius: 50%;
display: inline-block;
}
.preview-section {
background: var(--color-card, #1e293b);
border: 1px solid var(--color-card-border, #334155);
border-radius: 12px;
margin-bottom: 1.5rem;
overflow: hidden;
}
.preview-section-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem 1.5rem;
background: var(--color-surface, #0f172a);
border-bottom: 1px solid var(--color-card-border, #334155);
cursor: pointer;
user-select: none;
}
.preview-section-header:hover { background: var(--color-card-hover, #263044); }
.preview-section-header h3 {
font-size: 1.125rem;
margin: 0;
display: flex;
align-items: center;
gap: 0.5rem;
}
.preview-section-header .badge {
font-size: 0.7rem;
padding: 2px 8px;
border-radius: 9999px;
background: rgba(16, 185, 129, 0.15);
color: var(--color-accent, #22d3ee);
font-weight: 600;
}
.preview-section-body {
padding: 1.5rem;
max-height: 0;
overflow: hidden;
transition: max-height 0.4s ease;
}
.preview-section.open .preview-section-body {
max-height: 8000px;
}
.preview-section .chevron {
transition: transform 0.3s ease;
color: var(--color-text-muted, #94a3b8);
}
.preview-section.open .chevron { transform: rotate(180deg); }
.preview-code {
background: var(--color-bg-alt, #0f172a);
border: 1px solid var(--color-card-border, #334155);
border-radius: 8px;
padding: 1rem;
overflow-x: auto;
font-family: var(--font-mono, 'SF Mono', Consolas, monospace);
font-size: 0.8125rem;
line-height: 1.6;
white-space: pre;
color: var(--color-text, #f8fafc);
}
.preview-code .filename {
display: block;
color: var(--color-text-muted, #94a3b8);
font-size: 0.75rem;
margin-bottom: 0.5rem;
padding-bottom: 0.5rem;
border-bottom: 1px solid var(--color-card-border, #334155);
}
.file-tree {
font-family: var(--font-mono, 'SF Mono', Consolas, monospace);
font-size: 0.8125rem;
line-height: 1.8;
color: var(--color-text-muted, #94a3b8);
background: var(--color-bg-alt, #0f172a);
border: 1px solid var(--color-card-border, #334155);
border-radius: 8px;
padding: 1rem;
overflow-x: auto;
white-space: pre;
}
.file-tree .dir { color: var(--color-primary-light, #60a5fa); font-weight: 600; }
.file-tree .file { color: var(--color-text, #f8fafc); }
.readme-excerpt {
line-height: 1.7;
color: var(--color-text-muted, #94a3b8);
}
.readme-excerpt h3 { color: var(--color-text, #f8fafc); margin: 1.25rem 0 0.5rem; font-size: 1.1rem; }
.readme-excerpt h4 { color: var(--color-text, #f8fafc); margin: 1rem 0 0.5rem; font-size: 1rem; }
.readme-excerpt p { margin: 0.5rem 0; }
.readme-excerpt ul { margin: 0.5rem 0; padding-left: 1.5rem; }
.readme-excerpt li { margin: 0.25rem 0; }
.readme-excerpt code { background: var(--color-bg-alt, #0f172a); padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.85em; }
.readme-excerpt pre { background: var(--color-bg-alt, #0f172a); border: 1px solid var(--color-card-border, #334155); border-radius: 8px; padding: 1rem; overflow-x: auto; margin: 0.75rem 0; }
.readme-excerpt pre code { background: none; padding: 0; font-size: 0.8125rem; }
.readme-excerpt blockquote { border-left: 3px solid var(--color-primary, #3b82f6); margin: 0.75rem 0; padding: 0.5rem 1rem; color: var(--color-text-muted, #94a3b8); }
.preview-actions {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
margin-top: 2rem;
padding-top: 1.5rem;
border-top: 1px solid var(--color-card-border, #334155);
}
.redacted {
color: var(--color-text-muted, #64748b);
font-style: italic;
opacity: 0.6;
}
.redacted::before { content: "# "; }
@media (max-width: 640px) {
.preview-section-header { padding: 0.75rem 1rem; }
.preview-section-body { padding: 1rem; }
.preview-code, .file-tree { font-size: 0.7rem; }
.preview-header h1 { font-size: 1.25rem; }
}
</style>
<script defer data-domain="inity13.github.io" src="https://plausible.io/js/script.js"></script>
<!-- analytics-start -->
<script>
(function(){
try{
fetch("https://ferovwapilhcpqozqinn.supabase.co/rest/v1/page_views",{
method:"POST",
headers:{"Content-Type":"application/json","apikey":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZlcm92d2FwaWxoY3Bxb3pxaW5uIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzMwMTU3NTYsImV4cCI6MjA4ODU5MTc1Nn0.RhBBxPaAw5Fyzal5m3GY_sdxiIAp_RVJ_ki8CUgPnRY","Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZlcm92d2FwaWxoY3Bxb3pxaW5uIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzMwMTU3NTYsImV4cCI6MjA4ODU5MTc1Nn0.RhBBxPaAw5Fyzal5m3GY_sdxiIAp_RVJ_ki8CUgPnRY","Prefer":"return=minimal"},
body:JSON.stringify({store_name:"Python Developer Pro",page_path:location.pathname,referrer:document.referrer||null,user_agent:navigator.userAgent}),
keepalive:true
}).catch(function(){});
}catch(e){}
})();
</script>
<!-- analytics-end -->
</head>
<body>
<header class="site-header" role="banner">
<div class="container header-inner">
<a href="index.html" class="logo" aria-label="Python Developer Pro home">
<span class="logo-icon" aria-hidden="true">🐍</span>
Python Developer Pro
</a>
<nav class="nav-desktop" aria-label="Main navigation">
<a href="index.html#products">Products</a>
<a href="index.html#bundle">Bundle</a>
<a href="index.html#faq">FAQ</a>
</nav>
<div class="header-actions">
<button class="theme-toggle" aria-label="Toggle dark/light mode">
<svg class="icon-moon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg>
<svg class="icon-sun" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>
</button>
</div>
</div>
</header>
<main class="preview-page">
<div class="container">
<a href="index.html#products" class="preview-back">← Back to all products</a>
<div class="preview-header">
<div>
<h1>Python CLI Framework</h1>
</div>
<span class="price"><span class="currency">$</span>29</span>
</div>
<p class="preview-desc">Build professional CLI tools with Click/Typer, auto-completion, config management, and plugin architecture.</p>
<div class="preview-meta" style="display:flex;flex-wrap:wrap;gap:1rem;margin-bottom:1.5rem;font-size:0.875rem;color:var(--color-text-muted,#94a3b8);"><span>📁 16 files</span><span>🏷 v1.0.0</span></div>
<div class="preview-badges"><span class="preview-badge" style="border-color: #3776AB40; color: #3776AB;"><span class="dot" style="background: #3776AB;"></span>Python</span><span class="preview-badge" style="border-color: #9C412140; color: #9C4121;"><span class="dot" style="background: #9C4121;"></span>TOML</span><span class="preview-badge" style="border-color: #29292940; color: #292929;"><span class="dot" style="background: #292929;"></span>JSON</span><span class="preview-badge" style="border-color: #083FA140; color: #083FA1;"><span class="dot" style="background: #083FA1;"></span>Markdown</span></div>
<div class="preview-section open">
<div class="preview-section-header" onclick="this.parentElement.classList.toggle('open')">
<h3>📁 File Structure <span class="badge">16 files</span></h3>
<svg class="chevron" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>
</div>
<div class="preview-section-body">
<div class="file-tree"><span class="dir">python-cli-framework/</span>
├── <span class="file">LICENSE</span>
├── <span class="file">README.md</span>
├── <span class="dir">guides/</span>
│ └── <span class="file">building-cli-apps.md</span>
├── <span class="file">pyproject.toml</span>
├── <span class="dir">src/</span>
│ └── <span class="dir">cli/</span>
│ ├── <span class="dir">commands/</span>
│ │ ├── <span class="file">config.py</span>
│ │ ├── <span class="file">init.py</span>
│ │ └── <span class="file">run.py</span>
│ ├── <span class="file">config.py</span>
│ ├── <span class="file">logging_setup.py</span>
│ ├── <span class="file">main.py</span>
│ ├── <span class="file">output.py</span>
│ └── <span class="file">utils.py</span>
├── <span class="dir">templates/</span>
│ ├── <span class="file">README.md.j2</span>
│ └── <span class="file">pyproject.toml.j2</span>
└── <span class="dir">tests/</span>
├── <span class="file">test_cli.py</span>
└── <span class="file">test_config.py</span></div>
</div>
</div>
<div class="preview-section open">
<div class="preview-section-header" onclick="this.parentElement.classList.toggle('open')">
<h3>📖 Documentation Preview <span class="badge">README excerpt</span></h3>
<svg class="chevron" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>
</div>
<div class="preview-section-body">
<div class="readme-excerpt">
<h3>Python CLI Framework</h3>
<blockquote>Build beautiful, professional command-line tools with Click, Rich, and TOML configuration — from first command to PyPI package.</blockquote>
<p>[](https://www.python.org/downloads/)</p>
<p>[](https://click.palletsprojects.com)</p>
<p>[](LICENSE)</p>
<p>---</p>
<h3>What You Get</h3>
<ul>
<li><strong>Click-based CLI</strong> — Group commands with <code>--verbose</code>, <code>--output-format</code>, and <code>--config</code></li>
<li><strong>Rich output</strong> — Tables, JSON, YAML, and CSV formatters with color and progress bars</li>
<li><strong>TOML configuration</strong> — Read/write config files with environment variable fallback</li>
<li><strong>Project scaffolding</strong> — <code>init</code> command generates new project structure from Jinja2 templates</li>
<li><strong>Task runner</strong> — <code>run</code> command with Rich progress bars and error handling</li>
<li><strong>Structured logging</strong> — Rich console handler with optional file rotation</li>
<li><strong>Full test suite</strong> — Click CliRunner tests for every command</li>
<li><strong>Best practices guide</strong> — Building, testing, and distributing CLI apps</li>
</ul>
<h3>File Tree</h3>
<pre><code>
python-cli-framework/
├── src/
│ └── cli/
│ ├── main.py # CLI entry point with Click group
│ ├── commands/
│ │ ├── init.py # Project scaffolding command
│ │ ├── run.py # Task runner command
│ │ └── config.py # Config management command
│ ├── config.py # TOML config read/write
│ ├── output.py # Table/JSON/YAML/CSV formatters
│ ├── logging_setup.py # Structured logging
│ └── utils.py # Utility functions
├── templates/
│ ├── pyproject.toml.j2 # Project template
│ └── README.md.j2 # README template
├── tests/
│ ├── test_cli.py # CLI command tests
│ └── test_config.py # Config tests
├── guides/
│ └── building-cli-apps.md # Best practices guide
└── pyproject.toml # Package configuration
</code></pre>
<h3>Getting Started</h3>
<h4>1. Install</h4>
<pre><code class="lang-bash">
pip install -e ".[dev]"
</code></pre>
<h4>2. Try the CLI</h4>
<pre><code class="lang-bash">
# Initialize a new project
mycli init my-project --template default
*... continues with setup instructions, usage examples, and more.*
</code></pre>
</div>
</div>
</div>
<div class="preview-section">
<div class="preview-section-header" onclick="this.parentElement.classList.toggle('open')">
<h3>📄 Code Sample <span class="badge">.py preview</span></h3>
<svg class="chevron" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>
</div>
<div class="preview-section-body">
<div class="preview-code"><span class="filename">src/cli/config.py</span>
"""
Configuration management — TOML-based config with environment fallback.
Reads and writes a TOML configuration file with support for
dotted key paths, default values, and environment variable
overrides using the CLI_ prefix convention.
"""
from __future__ import annotations
import logging
import os
import sys
from pathlib import Path
from typing import Any
if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib
import tomli_w
logger = logging.getLogger(__name__)
DEFAULT_CONFIG: dict[str, Any] = {
"project": {
"name": "my-project",
"version": "0.1.0",
"author": "Developer",
},
"output": {
"color": True,
"format": "table",
},
"logging": {
"level": "INFO",
"file": None,
},
}
class ConfigManager:
"""Manage TOML configuration with environment variable overrides."""
ENV_PREFIX = "CLI_"
def __init__(self, path: Path) -> None:
self.path = path
self._data: dict[str, Any] = {}
# ... 100 more lines ...</div>
</div>
</div>
<div class="preview-actions">
<a href="https://buy.stripe.com/6oU7sLbD18WWdNE8ylgjC0s" class="btn btn-primary">Buy Now — $29</a>
<a href="index.html#products" class="btn btn-secondary btn-sm">Back to Products</a>
</div>
</div>
</main>
<footer class="site-footer" role="contentinfo">
<div class="container">
<div class="footer-bottom">
<p>© 2025 Python Developer Pro. All rights reserved.</p>
<div class="footer-bottom-links">
<a href="index.html">Store</a>
<a href="about.html">About</a>
<a href="mailto:megafolder122122@hotmail.com">Contact</a>
</div>
</div>
</div>
</footer>
<script src="script.js"></script>
</body>
</html>