Move main code to __init__.py to avoid Traceback errors

This commit is contained in:
samedamci 2021-08-26 22:46:35 +02:00
parent 85ba1b45ce
commit 1b5738b7e9
No known key found for this signature in database
GPG Key ID: FCB4A9A20D00E894
3 changed files with 23 additions and 17 deletions

18
guzzy/__init__.py Normal file
View File

@ -0,0 +1,18 @@
from os import listdir, path
from argparse import ArgumentParser
from subprocess import call
def main():
dir_path = path.join(path.dirname(path.realpath(__file__)), "commands")
commands = [x.replace(".sh", "") for x in listdir(dir_path)]
parser = ArgumentParser(
prog="guzzy",
description="Interactive CLI git client inside fzf.",
allow_abbrev=False,
)
parser.add_argument("command", choices=commands)
args = parser.parse_args()
call(path.join(dir_path, f"{args.command}.sh"), shell=True)

View File

@ -1,16 +1,4 @@
from os import listdir, path
from argparse import ArgumentParser
from subprocess import call
from . import main
dir_path = path.join(path.dirname(path.realpath(__file__)), "commands")
commands = [x.replace(".sh", "") for x in listdir(dir_path)]
parser = ArgumentParser(
prog="guzzy",
description="Interactive CLI git client inside fzf.",
allow_abbrev=False,
)
parser.add_argument("command", choices=commands)
args = parser.parse_args()
call(path.join(dir_path, f"{args.command}.sh"), shell=True)
if __name__ == "__main__":
main()

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "guzzy"
version = "0.1.0"
version = "0.1.1"
description = "Interactive CLI git client inside fzf."
authors = ["samedamci <samedamci@disroot.org>"]
license = "ISC"
@ -23,7 +23,7 @@ include = ["LICENSE"]
python = "^3.6"
[tool.poetry.scripts]
guzzy = "guzzy:__main__"
guzzy = "guzzy:main"
[build-system]
requires = ["poetry-core>=1.0.0"]