xy_argparse 模块
Project description
xy_argparse
说明
命令行参数简易工具.
源码仓库
安装
# bash
pip install xy_argparse
开始
# main.py
from argparse import Namespace
from xy_argparse.ArgParse import ArgParse
class Runner(ArgParse):
@property
def version(self):
return "0.0.1"
def __init__(self):
self.prog = "xy_conda"
self.description = "conda相关工具"
def main(self):
self.default_parser()
self.add_arguments()
self.parse_arguments()
if self.work:
self.run_arguments()
else:
self.parser.print_help()
def add_arguments(self):
self.add_argument(
flag="-w",
name="--work",
help_text="""
工作方式:
"backup",
"install",
"install_pack",
"load",
""",
)
def on_arguments(
self,
name,
value,
arguments=None,
):
if name == "work":
if value == "backup":
self.backup()
return False
elif value == "load":
self.load()
return False
elif value == "install":
self.install()
return False
elif value == "install_pack":
self.install_pack()
return False
return True
def backup(self):
print("output backup")
def load(self):
print("output load")
def install(self):
print("output install")
def install_pack(self):
print("output install_pack")
@property
def work(self):
arguments = self.arguments()
if isinstance(arguments, Namespace):
return arguments.work
return None
if __name__ == "__main__":
runner = Runner()
runner.main()
# bash
python main.py -w backup
# output backup
许可证
xy_argparse 根据 <木兰宽松许可证, 第2版> 获得许可。有关详细信息,请参阅 LICENSE 文件。
捐赠
如果小伙伴们觉得这些工具还不错的话,能否请咱喝一杯咖啡呢?
联系方式
微信: yuyangiit
邮箱: yuyangit.0515@qq.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xy_argparse-1.0.10.tar.gz
(9.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xy_argparse-1.0.10.tar.gz.
File metadata
- Download URL: xy_argparse-1.0.10.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d2f432fc5ee36db599eb547e737f6943a404236a47bfe8e42f65741c02e3e17
|
|
| MD5 |
0ebc65c59b07d62f004335aebd027a03
|
|
| BLAKE2b-256 |
7cba0b60b7121cc649b78354f1d406e59564957ff2539f4b7d31c4e1d5cbc17b
|
File details
Details for the file xy_argparse-1.0.10-py3-none-any.whl.
File metadata
- Download URL: xy_argparse-1.0.10-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
582c81a1c675969a00ad8634d8d7c488304d7ca1e249e34d597c0a168b259f36
|
|
| MD5 |
5fc9e705a2a44ff1deb73e49c45844fe
|
|
| BLAKE2b-256 |
bec76c27a52e1493b5b4badc02d0bbafac6d8348cfac2e9db6217fe47ec031ae
|