dhondta/python-tinyscript

GitHub: dhondta/python-tinyscript

一个基于 argparse 的 Python 开发工具包,通过预配置和星号导入帮助开发者用极少量代码快速构建美观的命令行工具。

Stars: 55 | Forks: 9

TinyScript Tweet

Make a CLI tool with very few lines of code.

[![PyPi](https://img.shields.io/pypi/v/tinyscript.svg)](https://pypi.python.org/pypi/tinyscript/) [![阅读文档](https://readthedocs.org/projects/python-tinyscript/badge/?version=latest)](https://python-tinyscript.readthedocs.io/en/latest/?badge=latest) [![构建状态](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/38dc94738f102128.svg)](https://github.com/dhondta/python-tinyscript/actions/workflows/python-package.yml) [![覆盖率状态](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/d9ae0021be102137.svg)](#) [![Python 版本](https://img.shields.io/pypi/pyversions/tinyscript.svg)](https://pypi.python.org/pypi/tinyscript/) [![已知漏洞](https://snyk.io/test/github/dhondta/python-tinyscript/badge.svg?targetFile=requirements.txt)](https://snyk.io/test/github/dhondta/python-tinyscript?targetFile=requirements.txt) [![许可证](https://img.shields.io/pypi/l/tinyscript.svg)](https://pypi.python.org/pypi/tinyscript/) 本库旨在提供有用的功能和辅助工具,以减少编写简单且美观的命令行界面工具所需的代码行数。它基于 `argparse`,被视为一个**开发包 (development kit)**,与 [`cement`](https://builtoncement.com/)、[`click`](https://click.palletsprojects.com) 或 [`docopt`](http://docopt.org) 等流行的**框架**不同,它的目标不是用另一种范式来重新发明轮子。 ``` pip install tinyscript ``` ## :bulb: 理念 本库遵循 DRY (*Don't Repeat Yourself*,不要重复自己) 和 KISS (*Keep It Stupid Simple*,保持极其简单) 的理念构建;Tinyscript 的整体机制在于其**星号导入** (`from tinyscript import *`) 及其**初始化** (通过 `initialize` 函数)。 它旨在通过在加载时设置一些内容来缩短所需的代码: - 一个[代理解析器](https://python-tinyscript.readthedocs.io/en/latest/internals.html#proxy-parser) (来自星号导入) 在初始化时收集参数定义并格式化帮助信息,避免了重写声明 [`ArgumentParser`](https://docs.python.org/3/library/argparse.html#example) (及其 epilog 等) 所需的大量代码 - 一个[主(彩色)日志记录器](https://python-tinyscript.readthedocs.io/en/latest/internals.html#pre-configured-colored-logger) 已预配置,并可通过两个常量进行调整,这样我们就无需关心配置日志所需的代码编写 - 常用库的[预导入](https://python-tinyscript.readthedocs.io/en/latest/internals.html#pre-imports) (虽然我们承认这有点反 Python 风格) 也减少了所需的代码量 - 其中,一些[模块被增强了](https://python-tinyscript.readthedocs.io/en/latest/enhancements.html),添加了原生未预见的新函数和类 利用这一点可以创建非常简短的脚本,其中**仅包含真正重要的代码**,从而减少为创建高效、美观且复杂的 CLI 工具而需重写的代码。 请注意,虽然根据 Python 的风格指南 (参见 [PEP8](https://pep8.org/#imports)) 应避免星号导入,但为了缩短代码长度,这里故意广泛使用了它,并覆盖了巨大的范围。这种“反模式”在创建了几个工具后会显现出价值,当我们意识到它缩短了通常从一个工具到另一个工具重复的代码部分时 (例如,用于塑造工具的帮助信息)。 ## :sunglasses: 用法 它的设计旨在尽可能简单直观。为了学习和使用它,您只需要您的浏览器 (用于查阅文档)、一个文本编辑器和一个好的 Python 解释器 (例如 [IDLE](https://docs.python.org/3/library/idle.html)) 以使用自动补全,或者像 [PyCharm](https://www.jetbrains.com/pycharm/) 这样的 IDE 来获取建议的帮助。 关键在于您将使用: - 通过在名为 `initialize` 的“主”函数中设置标志来启用的[功能](https://python-tinyscript.readthedocs.io/en/latest/utility.html) - 在名为 `ts` 的“主”子模块下分组的[辅助工具](https://python-tinyscript.readthedocs.io/en/latest/helpers.html) - 来自全局作用域的[报告](https://python-tinyscript.readthedocs.io/en/latest/reporting.html)对象 请参阅下方的[示例工具](#example-tools),了解功能、辅助工具和报告的用法示例。 ## :fast_forward: 快速开始 ### 从模板创建

### 编辑源码

### 运行您的工具

## :mag: 示例工具 ### 安全 - [AppMemDumper](https://github.com/dhondta/AppmemDumper) (Windows 取证) - [Bots Scheduler](https://github.com/dhondta/bots-scheduler) (Web 安全服务作业调度器) - [DroneSploit](https://github.com/dhondta/dronesploit) (启动脚本) - [Evil Pickle Creation Tool](https://gist.github.com/dhondta/0224d42a6f9dde00247ff8646f4e89aa) (Python evil pickle 生成工具) - [Malicious Macro Tester](https://github.com/dhondta/malicious-macro-tester) (恶意 VB 宏检测) - [Paddinganograph](https://gist.github.com/dhondta/90a07d9d106775b0cd29bb51ffe15954) (基于 base32/64 填充的隐写术) - [PDF Passwords Bruteforcer](https://gist.github.com/dhondta/efe84a92e4dfae3b6c14932c73ab2577) (暴力破解工具) - [Solitaire Cipher](https://gist.github.com/dhondta/1858f406fc55e5e5d440ff26432ad0a4) (加密) - [StegoLSB](https://gist.github.com/dhondta/d2151c82dcd9a610a7380df1c6a0272c) (最低有效位) - [StegoPIT](https://gist.github.com/dhondta/30abb35bb8ee86109d17437b11a1477a) (像素指示技术) - [StegoPVD](https://gist.github.com/dhondta/feaf4f5fb3ed8d1eb7515abe8cde4880) (像素值差分) - [STIX Report Generator](https://gist.github.com/dhondta/ca5fb748957b1ec6f13418ac41c94d5b) - [WLF (Word List Filter)](https://gist.github.com/dhondta/82a7919f8aafc1393c37c2d0f06b77e8) ### 工具 - [Audio Assembler](https://gist.github.com/dhondta/8b3c7d95b056cae3505df853a098fc4f) - [Documentation Text Masker](https://gist.github.com/dhondta/5cae9533240471eac155bd51593af2e0) - [Email Origin](https://gist.github.com/dhondta/9a8027062ff770b2aa5d8422ddd78b57) - [Loose Comparison Input Generator](https://gist.github.com/dhondta/8937374f087f708c608bcacac431969f) (PHP 类型戏法) - [PDF Preview Generator](https://gist.github.com/dhondta/f57dfde304905644ca5c43e48c249125) - [Recursive Compression](https://github.com/dhondta/recursive-compression) - [WebGrep](https://github.com/dhondta/webgrep) (Web 文本搜索) - [Zotero CLI](https://github.com/dhondta/zotero-cli) ## :clap: 支持者 [![@dhondta/python-tinyscript 的 Stargazers 仓库名单](https://reporoster.com/stars/dark/dhondta/python-tinyscript)](https://github.com/dhondta/python-tinyscript/stargazers) [![@dhondta/python-tinyscript 的 Forkers 仓库名单](https://reporoster.com/forks/dark/dhondta/python-tinyscript)](https://github.com/dhondta/python-tinyscript/network/members)

Back to top

标签:Argparse, CTF工具, Devkit, DNS解析, PyPI, Python, 代码库, 命令行应用, 命令行界面, 开发工具包, 开发框架, 开源项目, 快速开发, 无后门, 漏洞搜索, 网络调试, 脚本编程, 自动化, 逆向工具