Add main() function

This commit is contained in:
ge 2022-04-08 21:27:45 +03:00
parent ff8eaad69a
commit f4ba7e9803
2 changed files with 6 additions and 3 deletions

View File

@ -20,13 +20,14 @@ setup(
python_requires = '>=3.6', python_requires = '>=3.6',
py_modules = ['twvdscli'], py_modules = ['twvdscli'],
install_requires = [ install_requires = [
'click==7.1.1'
'typer==0.4.0', 'typer==0.4.0',
'prettytable==3.2.0', 'prettytable==3.2.0',
'wcwidth==0.2.5' 'wcwidth==0.2.5'
], ],
entry_points = { entry_points = {
'console_scripts': [ 'console_scripts': [
'twvdscli = twvdscli' 'twvdscli = twvdscli:main'
] ]
} }
) )

View File

@ -323,11 +323,13 @@ def get_api_key():
result = auth(based) result = auth(based)
return result return result
def main():
if __name__ == '__main__':
apikey = get_api_key() apikey = get_api_key()
if apikey is None: if apikey is None:
print(typer.style("Auth Error", fg=typer.colors.RED)) print(typer.style("Auth Error", fg=typer.colors.RED))
sys.exit(1) sys.exit(1)
reqHeader = {"Authorization": "Bearer " + apikey} reqHeader = {"Authorization": "Bearer " + apikey}
app() app()
if __name__ == '__main__':
main()