From 16b7c7af5d4ca5d7befe8d9a586c9e8c76bfa662 Mon Sep 17 00:00:00 2001 From: Morgan Courbet Date: Thu, 15 Jun 2017 20:29:28 +0200 Subject: [PATCH] Use Enum to list line ending types in mixed_line_ending --- pre_commit_hooks/mixed_line_ending.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pre_commit_hooks/mixed_line_ending.py b/pre_commit_hooks/mixed_line_ending.py index 612cdc9..bc863be 100644 --- a/pre_commit_hooks/mixed_line_ending.py +++ b/pre_commit_hooks/mixed_line_ending.py @@ -1,13 +1,25 @@ import argparse import sys +from enum import Enum + + +class LineEnding(Enum): + CRLF = '\r\n', '\\r\\n', 'crlf' + LF = '\n', '\\n', 'lf' + + def __init__(self, str, strPrint, optName): + self.str = str + self.strPrint = strPrint + self.optName = optName + def mixed_line_ending(argv=None): parser = argparse.ArgumentParser() parser.add_argument( '-f', '--fix', - choices=['auto', 'crlf', 'lf', 'no'], + choices=['auto', 'no'] + [m.optName for m in LineEnding], default='auto', help='Replace line ending with the specified. Default is "auto"', nargs=1)