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/

https://blog.csdn.net/qq_17550379/article/details/79943740

https://github.com/google/python-fire

posted @   michaelchengjl  阅读(149)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
历史上的今天:
2022-09-05 nvidia-smi 命令参数含义, nvitop
点击右上角即可分享
微信分享提示