CLI interface. Sys_argv is a parameter for the sake of unittest coverage. :param sys_argv list: :rtype: None
(sys_argv=None)
| 769 | |
| 770 | |
| 771 | def main(sys_argv=None): |
| 772 | """ |
| 773 | CLI interface. Sys_argv is a parameter for the sake of unittest coverage. |
| 774 | :param sys_argv list: |
| 775 | :rtype: None |
| 776 | """ |
| 777 | parser = argparse.ArgumentParser( |
| 778 | description=DESCRIPTION, |
| 779 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) |
| 780 | parser.add_argument( |
| 781 | 'sources', metavar='sources', nargs='+', |
| 782 | help='source code file/directory paths.') |
| 783 | parser.add_argument( |
| 784 | '--output', '-o', default='out.png', |
| 785 | help=f'output file path. Supported types are {VALID_EXTENSIONS}.') |
| 786 | parser.add_argument( |
| 787 | '--language', choices=['py', 'js', 'rb', 'php'], |
| 788 | help='process this language and ignore all other files.' |
| 789 | 'If omitted, use the suffix of the first source file.') |
| 790 | parser.add_argument( |
| 791 | '--target-function', |
| 792 | help='output a subset of the graph centered on this function. ' |
| 793 | 'Valid formats include `func`, `class.func`, and `file::class.func`. ' |
| 794 | 'Requires --upstream-depth and/or --downstream-depth. ') |
| 795 | parser.add_argument( |
| 796 | '--upstream-depth', type=int, default=0, |
| 797 | help='include n nodes upstream of --target-function.') |
| 798 | parser.add_argument( |
| 799 | '--downstream-depth', type=int, default=0, |
| 800 | help='include n nodes downstream of --target-function.') |
| 801 | parser.add_argument( |
| 802 | '--exclude-functions', |
| 803 | help='exclude functions from the output. Comma delimited.') |
| 804 | parser.add_argument( |
| 805 | '--exclude-namespaces', |
| 806 | help='exclude namespaces (Classes, modules, etc) from the output. Comma delimited.') |
| 807 | parser.add_argument( |
| 808 | '--include-only-functions', |
| 809 | help='include only functions in the output. Comma delimited.') |
| 810 | parser.add_argument( |
| 811 | '--include-only-namespaces', |
| 812 | help='include only namespaces (Classes, modules, etc) in the output. Comma delimited.') |
| 813 | parser.add_argument( |
| 814 | '--no-grouping', action='store_true', |
| 815 | help='instead of grouping functions into namespaces, let functions float.') |
| 816 | parser.add_argument( |
| 817 | '--no-trimming', action='store_true', |
| 818 | help='show all functions/namespaces whether or not they connect to anything.') |
| 819 | parser.add_argument( |
| 820 | '--hide-legend', action='store_true', |
| 821 | help='by default, Code2flow generates a small legend. This flag hides it.') |
| 822 | parser.add_argument( |
| 823 | '--skip-parse-errors', action='store_true', |
| 824 | help='skip files that the language parser fails on.') |
| 825 | parser.add_argument( |
| 826 | '--source-type', choices=['script', 'module'], default='script', |
| 827 | help='js only. Parse the source as scripts (commonJS) or modules (es6)') |
| 828 | parser.add_argument( |