| Conditions | 5 |
| Total Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | # This program is free software: you can redistribute it and/or modify it |
||
| 22 | def main(): |
||
| 23 | log_printer = ListLogPrinter() |
||
| 24 | |||
| 25 | results, exitcode = run_coala(log_printer, autoapply=False) |
||
| 26 | |||
| 27 | retval = {"logs": log_printer.logs, "results": results} |
||
| 28 | if len(sys.argv) > 2: |
||
| 29 | try: |
||
| 30 | flag = sys.argv[-2] |
||
| 31 | filename = sys.argv[-1] |
||
| 32 | if flag == '-o': |
||
| 33 | with open(filename, "w") as fi: |
||
| 34 | fi.write(json.dumps(retval, |
||
| 35 | cls=JSONEncoder, |
||
| 36 | sort_keys=True, |
||
| 37 | indent=2, |
||
| 38 | separators=(',', ': '))) |
||
| 39 | print('Output has been written to ' + filename) |
||
| 40 | else: |
||
| 41 | print('There has been an error in the syntax.\n\ |
||
| 42 | Please try coala-json -o <filename.json>') |
||
| 43 | except IndexError: |
||
| 44 | pass |
||
| 45 | else: |
||
| 46 | print(json.dumps(retval, |
||
| 47 | cls=JSONEncoder, |
||
| 48 | sort_keys=True, |
||
| 49 | indent=2, |
||
| 50 | separators=(',', ': '))) |
||
| 51 | |||
| 52 | return exitcode |
||
| 53 |