Python 命令行工具库:Fire
Python 命令行工具库:Fire
Python Fire 是 Google 开源的一个可从任何 Python 代码自动生成命令行接口(CLI)的库。
Python Fire 是一种在 Python 中创建 CLI 的简单方法。
Python Fire 是开发和调试 Python 代码的有用工具。
Python Fire 帮助探索现有代码或将其他人的代码转换为CLI。
Python Fire 使 Bash 和 Python 之间的转换更为容易。
Python Fire 通过使用你需要导入和创建的模块和变量来设置 REPL,使得使用 Python REPL 更容易。
之前用过的一个生成命令行参数的模块:argparse, fire 模块的功能比 argparse 强大得多,用起来也更为顺手
Setup | Command Notes |
---|---|
install pip install fire | |
Creating a CLI Command Notes | |
import import fire | |
Call fire.Fire() Turns the current module into a Fire CLI. | |
Call fire.Fire(component) Turns component into a Fire CLI. | |
Using a CLI Command Notes | |
Help command --help or command -- --help | |
REPL command -- --interactive Enters interactive mode. | |
Separator command -- --separator=X Sets the separator to X. The default separator is -. | |
Completion command -- --completion [shell] Generates a completion script for the CLI. | |
Trace command -- --trace Gets a Fire trace for the command. | |
Verbose command -- --verbose |
Note that these flags are separated from the Fire command by an isolated --.
https://google.github.io/python-fire/guide/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
2022-09-05 nvidia-smi 命令参数含义, nvitop