添加源管理功能

This commit is contained in:
root 2024-03-30 10:01:56 +08:00
parent 6dc1c8a374
commit 61860b0b71
2 changed files with 24 additions and 1 deletions

View File

@ -1,6 +1,8 @@
import click
from . import update as updates
from . import util
from moyanlib import jsons
import os
from . import install as installs
from . import search as searchs
@click.group()
@ -42,5 +44,25 @@ def remove(name,yes):
@click.option('--api-url','-u',default=None)
def search(*args, **kwargs):
searchs.main(*args,**kwargs)
@cli.group()
def source():
pass
@source.command()
@click.argument('url')
def add(url):
sourceList = jsons.load(open(os.path.join(util.dirs.user_config_dir,'Source.json')))
if url in sourceList:
print('The source already exists')
exit()
sourceList.append(url)
jsons.dump(sourceList,open(os.path.join(util.dirs.user_config_dir,'Source.json')))
@source.command(name='list')
def lists():
sourceList = jsons.load(open(os.path.join(util.dirs.user_config_dir,'Source.json')))
ids = 1
for i in sourceList:
print(str(ids)+'.',i)
if __name__ == '__main__':
cli()

View File

@ -14,13 +14,14 @@ class CustomInstallCommand(install):
open(os.path.join(dirs.user_config_dir,'Source.json'),'w').write('["https://pypi.org/simple/"]')
open(os.path.join(dirs.user_config_dir,'api.url'),'w').write('https://pypi.org/pypi/{}/json')
setup(
name='pmpt', # 包的名称
version=util.__version__, # 版本号
packages=find_packages(), # 包含的包
author='MoYan', # 作者
author_email='moyan@moyanjdc.top', # 作者邮箱
description='a Python Package Advanced Manager', # 包的简要描述
description='A Python Package Advanced Manager', # 包的简要描述
long_description='A longer description of your package', # 包的详细描述
long_description_content_type='text/markdown', # 描述的内容类型
classifiers=[ # 包的分类信息