Skip to content

Commit

Permalink
[FIX] addin CLI commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafabarmshory committed Feb 3, 2025
1 parent 682067f commit c044d80
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 40 deletions.
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ testing =
#
console_scripts =
otoolbox = otoolbox:run
otoolbox-workspace = otoolbox.workspace:run
otoolbox-repo = otoolbox.repositories:run


[tool:pytest]
Expand Down
55 changes: 27 additions & 28 deletions src/otoolbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from otoolbox import utils

from otoolbox.constants import (
ERROR_CODE_PRE_VERIFICATION,
ERROR_CODE_POST_VERIFICATION

ERROR_CODE_PRE_VERIFICATION,
ERROR_CODE_POST_VERIFICATION

)

Expand All @@ -35,24 +35,20 @@
del version, PackageNotFoundError






# def init_cli():
# """Initialize the command-line interface for the Odoo Toolbox."""
# arg_parser = argparse.ArgumentParser(
# prog='odoo-util',
# description="""
# Odoonix Toolbox is a comprehensive suite of tools designed to streamline
# the workflows of developers and maintainers working with Odoo. It
# simplifies tasks such as tracking changes in addons, cloning
# repositories, managing databases, and configuring development
# environments. With its user-friendly interface and automation
# features, Odoonix Toolbox enables teams to maintain consistency,
# reduce manual effort, and speed up development cycles. By integrating
# essential functionalities into one cohesive package, it empowers
# developers to focus on creating and maintaining high-quality Odoo
# Odoonix Toolbox is a comprehensive suite of tools designed to streamline
# the workflows of developers and maintainers working with Odoo. It
# simplifies tasks such as tracking changes in addons, cloning
# repositories, managing databases, and configuring development
# environments. With its user-friendly interface and automation
# features, Odoonix Toolbox enables teams to maintain consistency,
# reduce manual effort, and speed up development cycles. By integrating
# essential functionalities into one cohesive package, it empowers
# developers to focus on creating and maintaining high-quality Odoo
# solutions efficiently.
# """,
# epilog='Developer toolbox'
Expand Down Expand Up @@ -95,8 +91,8 @@ def _load_resources(*args):
package.init()



if __name__ == '__main__':
def run():
"""Run the application"""
_load_resources(
'otoolbox.addons.help',
'otoolbox.addons.workspace',
Expand All @@ -105,20 +101,19 @@ def _load_resources(*args):
'otoolbox.addons.repositories'
)


def callback_common_arguments(
odoo:str='18.0',
path:str='.',
silent:bool=False,
pre_check:bool=False,
post_check:bool=False,
continue_on_exception:bool=True
):
odoo: str = '18.0',
path: str = '.',
silent: bool = False,
pre_check: bool = False,
post_check: bool = False,
continue_on_exception: bool = True
):
env.context.update({
'odoo_version': odoo,
'path': path,
'silent': silent,
'pre_check':pre_check,
'pre_check': pre_check,
'post_check': post_check,
'continue_on_exception': continue_on_exception
})
Expand All @@ -133,7 +128,7 @@ def callback_common_arguments(
def result_callback(*args, **kargs):
if env.context.get('post_check', False):
utils.verify_all_resource()

# Launch the CLI application
app = typer.Typer(
callback=callback_common_arguments,
Expand All @@ -144,3 +139,7 @@ def result_callback(*args, **kargs):
app.add_typer(repositories.app, name="repo")
app.add_typer(developer.app, name="dev")
app()


if __name__ == '__main__':
run()
25 changes: 17 additions & 8 deletions src/otoolbox/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import typer



from otoolbox import env
# from otoolbox.repositories import admin

Expand All @@ -23,29 +22,30 @@
def _filter_resources():
resources = (
env.context
.get('resources')
.filter(lambda resource: resource.has_tag('git'))
.get('resources')
.filter(lambda resource: resource.has_tag('git'))
)
return resources;
return resources


@app.command()
def info():
"""Display information about the workspace"""
pass


@app.command()
def init():
"""Initialize all resources from addons into the current workspace"""
return _filter_resources().build()


@app.command()
def update():
"""Updates current workspace to the latest version"""
return _filter_resources().update()




# def add_repo_list_filter(parser):
# parser.add_argument(
# '--oca',
Expand Down Expand Up @@ -73,15 +73,15 @@ def update():
# '--no-moonsunsoft',
# dest='python',
# action='store_false')

# def init_cli(parent_parser):
# """Init CLI to support maintainer tools
# """
# admin_parseer = parent_parser.add_parser('admin',)
# admin_subparser = admin_parseer.add_subparsers(
# title="Administrator Tools",
# description="""
# Tools and Utilites to help administrators. It makes simple to
# Tools and Utilites to help administrators. It makes simple to
# keep dev repositories up to date.
# """)

Expand All @@ -100,3 +100,12 @@ def update():
# common.add_repo_list_filter(dev_info)

# return admin_parseer


def run():
"""Run the application"""
app()


if __name__ == "__main__":
run()
15 changes: 11 additions & 4 deletions src/otoolbox/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
pretty_exceptions_show_locals=False
)


@app.command()
def init():
"""Initialize all resources from addons into the current workspace"""
resources = env.context.get('resources')
resources.build()


@app.command()
def verify():
# check if verification is performed by the system
# check if verification is performed by the system
if env.context.get('pre_check', False) or env.context.get('post_check', False):
return
result, verified, total = utils.verify_all_resource(should_exit=False)
Expand All @@ -25,6 +27,7 @@ def verify():
else:
print("Success")


@app.command()
def delete():
resources = env.context.get('resources')
Expand All @@ -51,14 +54,13 @@ def update():
resources.update()



# def init_cli(parent_parser):
# """Init CLI to support maintainer tools
# """
# init_parseer = parent_parser.add_parser(
# 'init',
# description="""
# Tools and Utilites to help developers and maintainers. It makes simple to
# Tools and Utilites to help developers and maintainers. It makes simple to
# keep dev repositories up to date.
# """)
# init_parseer.set_defaults(func=_init_resources)
Expand All @@ -81,6 +83,11 @@ def update():
# return parent_parser


def run():
"""Run the application"""
app()


# Launch application if called directly
if __name__ == "__main__":
app()
run()

0 comments on commit c044d80

Please sign in to comment.