Commit 9977c523e844c48202c794a0f5a0c2e5a89b2fe9
1 parent
3f009e76
oleobj: accept custom command line args for testing
Showing
1 changed file
with
7 additions
and
3 deletions
oletools/oleobj.py
| @@ -667,8 +667,12 @@ def existing_file(filename): | @@ -667,8 +667,12 @@ def existing_file(filename): | ||
| 667 | return filename | 667 | return filename |
| 668 | 668 | ||
| 669 | 669 | ||
| 670 | -def main(): | ||
| 671 | - """ main function, called when running this as script """ | 670 | +def main(cmd_line_args=None): |
| 671 | + """ main function, called when running this as script | ||
| 672 | + | ||
| 673 | + Per default (cmd_line_args=None) uses sys.argv. For testing, however, can | ||
| 674 | + provide other arguments. | ||
| 675 | + """ | ||
| 672 | # print banner with version | 676 | # print banner with version |
| 673 | print('oleobj %s - http://decalage.info/oletools' % __version__) | 677 | print('oleobj %s - http://decalage.info/oletools' % __version__) |
| 674 | print('THIS IS WORK IN PROGRESS - Check updates regularly!') | 678 | print('THIS IS WORK IN PROGRESS - Check updates regularly!') |
| @@ -711,7 +715,7 @@ def main(): | @@ -711,7 +715,7 @@ def main(): | ||
| 711 | help='verbose mode, set logging to DEBUG ' | 715 | help='verbose mode, set logging to DEBUG ' |
| 712 | '(overwrites -l)') | 716 | '(overwrites -l)') |
| 713 | 717 | ||
| 714 | - options = parser.parse_args() | 718 | + options = parser.parse_args(cmd_line_args) |
| 715 | if options.more_input: | 719 | if options.more_input: |
| 716 | options.input += [options.more_input, ] | 720 | options.input += [options.more_input, ] |
| 717 | if options.verbose: | 721 | if options.verbose: |