diff --git a/guzzy/__init__.py b/guzzy/__init__.py new file mode 100644 index 0000000..75d5289 --- /dev/null +++ b/guzzy/__init__.py @@ -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) diff --git a/guzzy/__main__.py b/guzzy/__main__.py index d0736e2..868d99e 100644 --- a/guzzy/__main__.py +++ b/guzzy/__main__.py @@ -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() diff --git a/pyproject.toml b/pyproject.toml index 763af08..8cefd38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] 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"]