Coverage for mfplugin/cli_tools/plugins_develop.py: 0%
36 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-13 15:57 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-13 15:57 +0000
1#!/usr/bin/env python3
3import os
4import argparse
5import sys
6from mfplugin.manager import PluginsManager
7from mfplugin.utils import AlreadyInstalledPlugin
8from mfutil.cli import echo_ok, echo_running, echo_nok, echo_bold, echo_warning
10DESCRIPTION = "develop a plugin from a directory"
11MFMODULE_LOWERCASE = os.environ.get('MFMODULE_LOWERCASE', 'mfext')
14def main():
15 arg_parser = argparse.ArgumentParser(description=DESCRIPTION)
16 arg_parser.add_argument("--plugin-path", default=".",
17 help="plugin directory path")
18 arg_parser.add_argument("--ignore-already-installed", action="store_true",
19 help="ignore already installed plugin "
20 "(in dev mode)")
21 arg_parser.add_argument("name",
22 help="plugin name")
23 args = arg_parser.parse_args()
24 manager = PluginsManager()
25 echo_running("- Devlinking plugin %s..." % args.name)
26 try:
27 manager.develop_plugin(args.plugin_path)
28 except AlreadyInstalledPlugin:
29 if args.ignore_already_installed:
30 p = manager.make_plugin(args.plugin_path)
31 if p.is_installed and p.is_dev_linked:
32 echo_warning("(already installed)")
33 sys.exit(0)
34 echo_nok()
35 echo_bold("ERROR: the plugin is already installed")
36 sys.exit(3)
37 except Exception as e:
38 echo_nok()
39 echo_bold(str(e))
40 sys.exit(2)
41 echo_ok()
42 p = manager.get_plugin(args.name)
43 p.print_dangerous_state()
46if __name__ == '__main__':
47 main()