类似 systemctl start myservice 后台启动后,程序初始化后,就可以在linux界面输入 myservice command arg.. 这样来完成一些工作。希望了解以下大致的实现过程,以及能帮得上忙的模块或者教程,我自己再去研究一下。
主要是想把现在零散的运维工作汇集一下,能灵活得管理工作中使用的各个脚本、程序
类似 systemctl start myservice 后台启动后,程序初始化后,就可以在linux界面输入 myservice command arg.. 这样来完成一些工作。希望了解以下大致的实现过程,以及能帮得上忙的模块或者教程,我自己再去研究一下。
主要是想把现在零散的运维工作汇集一下,能灵活得管理工作中使用的各个脚本、程序
可以使用谷歌出品的Fire构建命令行/
github地址:https://github.com/google/pyt...
官方文档介绍如下。
Python Fire is a library for creating command line interfaces (CLIs) from absolutely any Python object.
Python Fire is a simple way to create a CLI in Python.
Python Fire is a helpful tool for developing and debugging Python code.
Python Fire helps with exploring existing code or turning other people’s code into a CLI.
Python Fire makes transitioning between Bash and Python easier.
Python Fire makes using a Python REPL easier by setting up the REPL with the modules and variables you’ll need already imported and created.
prompt_toolkit # 强大的命令行交互
click # 命令行神器
cli_helpers # 强大的输出更好看
结合以上三种的pg神器pgcli开源全python命令行交互 https://github.com/dbcli/pgcl...
4 回答4.4k 阅读✓ 已解决
4 回答3.8k 阅读✓ 已解决
1 回答3k 阅读✓ 已解决
3 回答2.1k 阅读✓ 已解决
1 回答4.5k 阅读✓ 已解决
1 回答3.8k 阅读✓ 已解决
1 回答2.8k 阅读✓ 已解决
搜索下python daemon就可以找到一堆。
如果想更普遍一点弄个:
先开发个server端,开个命名管道等待cli client接入发送指令。
再开发个简单的cli client把指令通过命名管道发给server。命令解析用argpare就可以了