Skip to content

Commit

Permalink
mepo3 related changes in pyproject.toml and src/mepo3/__main__.py. Al…
Browse files Browse the repository at this point in the history
…so added etc/mepo3-cd.bash
  • Loading branch information
pchakraborty committed May 13, 2024
1 parent 81d425b commit 8b83441
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
26 changes: 26 additions & 0 deletions etc/mepo3-cd.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function usage_ () {
echo "usage: "
echo " mepo3-cd : cd to root of mepo3 project"
echo " mepo3-cd <component> : cd to directory of <component>"
echo ""
echo "mepo3-cd accepts only 0 or 1 arguments"
}

function mepo3-cd () {
if [ "$#" -gt 1 ]; then
usage_
return 1
fi
if [ "$1" == "-h" ]; then
usage_
return 0
fi
if [ "$#" -eq 0 ]; then
output=$(python -m mepo3 whereis _root)
else
output=$(python -m mepo3 whereis -i $1)
fi
if [ $? -eq 0 ]; then
cd $output
fi
}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pylint = "^3.1.0"

[tool.poetry.scripts]
mepo = "mepo.__main__:main"
mepo3 = "mepo3.__main__:main"

[build-system]
requires = ["poetry-core"]
Expand Down
6 changes: 3 additions & 3 deletions src/mepo3/__main__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from importlib import import_module

from mepo.cmdline.parser import MepoArgParser
from mepo.utilities import mepoconfig
from mepo3.cmdline.parser import MepoArgParser
from mepo3.utilities import mepoconfig


def main():
args = MepoArgParser().parse()
mepo_cmd = mepoconfig.get_alias_command(args.mepo_cmd)

# Load the module containing the "run" method of specified command
cmd_module = import_module(f"mepo.command.{mepo_cmd}")
cmd_module = import_module(f"mepo3.command.{mepo_cmd}")

# Execute "run" method of specified command
cmd_module.run(args)
Expand Down

0 comments on commit 8b83441

Please sign in to comment.