今日已更新 44 条资讯 | 累计 42753 条内容
关于我们

I Built a Python CLI Toolbox Instead of Writing One-Off Scripts

Mehak. 2026年09月13日 23:51 1 次阅读 来源:Dev.to

Whenever I ask an AI assistant to do a small task, it writes a quick Python script for me. Convert an image. Compress a PDF. Convert a CSV to Excel. The script works, I use it once, and then it disappears. At some point I thought: Why keep asking for one-off scripts when I could build my own reusable toolbox? So I did. Toolbox is a small Python CLI with utilities for the file and image tasks I keep needing — CSV ↔ Excel conversion, image grayscale/blur/compress, and PDF compression. Code here: GitHub Repository I had just finished the freeCodeCamp Python certification and wanted to use it for something instead of stopping at the certificate. My background is mainly Node.js, so this also turned into a tour of how Python projects differ from what I already know. From npm to uv The first thing I had to figure out wasn't Python syntax. It was package management. In Node I install with npm install , dependencies live in package.json , and versions lock in package-lock.json . In Python I first came across pip with requirements.txt — you install things, then freeze them into a file yourself with pip freeze > requirements.txt . Coming from Node, generating a lockfile by hand felt backwards. Then I found uv , a modern Python package and project manager that handles project creation, dependencies, virtual environments and lockfiles. Most of it mapped straight onto what I already knew: Node.js uv npm init uv init package.json pyproject.toml package-lock.json uv.lock npm install <pkg> uv add <pkg> npm ci uv sync npx <tool> uvx <tool> npm install -g . uv tool install . I never had to activate a virtual environment or regenerate a requirements file. And anyone cloning the project runs uv sync and gets the same environment I have. That's the point where Python started feeling normal to me. Structuring the CLI I organized Toolbox like this: toolbox/ ├── src/ │ └── toolbox/ │ ├── commands/ │ ├── utils/ │ └── __init__.py ├── tests/ ├── pyproject.toml └── uv.lock Commands go in comman

本文内容来源于互联网,版权归原作者所有
查看原文