Coverage for mfplugin/cli_tools/plugins_make.py: 0%

27 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-11-13 15:57 +0000

1#!/usr/bin/env python3 

2 

3import argparse 

4from mfplugin.manager import PluginsManager 

5from mfutil.cli import echo_ok, echo_running, echo_nok, echo_bold 

6 

7DESCRIPTION = "make a plugin from the current directory" 

8 

9 

10def main(): 

11 arg_parser = argparse.ArgumentParser(description=DESCRIPTION) 

12 arg_parser.add_argument("--plugin-path", default=".", 

13 help="plugin directory path") 

14 arg_parser.add_argument("--debug", action="store_true", 

15 help="add some debug informations in " 

16 "case of problems") 

17 arg_parser.add_argument("--show-plugin-path", action="store_true", 

18 default=False, 

19 help="show the generated plugin path") 

20 args = arg_parser.parse_args() 

21 echo_running("- Building plugin...") 

22 manager = PluginsManager() 

23 try: 

24 plugin = manager.make_plugin(args.plugin_path) 

25 path = plugin.build() 

26 except Exception as e: 

27 echo_nok() 

28 print(e) 

29 if args.debug: 

30 print("details of the problem:") 

31 raise e 

32 else: 

33 print("note: use --debug option for more details") 

34 else: 

35 echo_ok() 

36 if args.show_plugin_path: 

37 echo_bold("plugin file is ready at %s" % path) 

38 

39 

40if __name__ == '__main__': 

41 main()