-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__main__.py
30 lines (23 loc) · 1.07 KB
/
__main__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import argparse
import sys
from line_updates.AddSuffix import add_suffix
def get_user_inputs():
"""
Function to get user inputs
"""
# Input variable definition
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
description='Script which add a suffix to all lines of a given file.')
parser.add_argument('suffix', help='suffix which will be added to each line', type=str)
parser.add_argument('file_path', help='path of the file which need to be updated', type=str)
parser.add_argument('-output_file', help='path where you want to store the result. If not defined, the output file '
'will be the input file', type=str)
return parser.parse_args()
def main(argv):
user_inputs = get_user_inputs()
suffix = user_inputs.suffix
file_path = user_inputs.file_path
output_file = user_inputs.output_file if user_inputs.output_file else ''
add_suffix(suffix, file_path, output_file)
if __name__ == "__main__":
main(sys.argv[1:])