mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-08 12:34:17 +00:00
Use Enum to list line ending types in mixed_line_ending
This commit is contained in:
parent
3d4fb41d8a
commit
16b7c7af5d
1 changed files with 13 additions and 1 deletions
|
|
@ -1,13 +1,25 @@
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
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):
|
def mixed_line_ending(argv=None):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-f',
|
'-f',
|
||||||
'--fix',
|
'--fix',
|
||||||
choices=['auto', 'crlf', 'lf', 'no'],
|
choices=['auto', 'no'] + [m.optName for m in LineEnding],
|
||||||
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