mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 11:36:54 +00:00
Add enum to mixed_line_ending --fix option
This commit is contained in:
parent
16b7c7af5d
commit
afaa97cd11
1 changed files with 16 additions and 4 deletions
|
|
@ -4,22 +4,34 @@ import sys
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
class LineEnding(Enum):
|
class CLIOption(Enum):
|
||||||
|
def __init__(self, optName):
|
||||||
|
self.optName = optName
|
||||||
|
|
||||||
|
|
||||||
|
class LineEnding(CLIOption):
|
||||||
CRLF = '\r\n', '\\r\\n', 'crlf'
|
CRLF = '\r\n', '\\r\\n', 'crlf'
|
||||||
LF = '\n', '\\n', 'lf'
|
LF = '\n', '\\n', 'lf'
|
||||||
|
|
||||||
def __init__(self, str, strPrint, optName):
|
def __init__(self, string, strPrint, optName):
|
||||||
self.str = str
|
self.string = string
|
||||||
self.strPrint = strPrint
|
self.strPrint = strPrint
|
||||||
self.optName = optName
|
self.optName = optName
|
||||||
|
|
||||||
|
|
||||||
|
class MixedLineEndingOption(CLIOption):
|
||||||
|
AUTO = 'auto'
|
||||||
|
NO = 'no'
|
||||||
|
CRLF = LineEnding.CRLF.optName
|
||||||
|
LF = LineEnding.LF.optName
|
||||||
|
|
||||||
|
|
||||||
def mixed_line_ending(argv=None):
|
def mixed_line_ending(argv=None):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-f',
|
'-f',
|
||||||
'--fix',
|
'--fix',
|
||||||
choices=['auto', 'no'] + [m.optName for m in LineEnding],
|
choices=[m.optName for m in MixedLineEndingOption],
|
||||||
default='auto',
|
default='auto',
|
||||||
help='Replace line ending with the specified. Default is "auto"',
|
help='Replace line ending with the specified. Default is "auto"',
|
||||||
nargs=1)
|
nargs=1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue