-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathargs_parser.py
More file actions
62 lines (52 loc) · 1.4 KB
/
args_parser.py
File metadata and controls
62 lines (52 loc) · 1.4 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from argparse import ArgumentParser
from pathlib import Path
from constants import MERGER_COMMAND_NAME, REPEATER_COMMAND_NAME
parser = ArgumentParser(
description="Basic python script to merge pdf files in specific dir, and repeat n files in one"
)
subparsers = parser.add_subparsers(dest="command")
merger_parser = subparsers.add_parser(
MERGER_COMMAND_NAME,
help="Merge all PDF in provided dir",
usage="pdf_merger merge -d ./ -o ./result.pdf",
)
merger_parser.add_argument(
"--dir",
"-d",
type=Path,
dest="directory",
help="Directory with pdf files to merge",
)
merger_parser.add_argument(
"--output",
"-o",
type=Path,
dest="output",
help="File (with .pdf suffix) to write the result. The directory needs to be existent.",
)
repeater_parser = subparsers.add_parser(
REPEATER_COMMAND_NAME,
help="Merge the provided .pdf file n time in one file",
usage="pdf_merger repeat -f ./file.pdf -n 3 -o ./result.pdf",
)
repeater_parser.add_argument(
"--number",
"-n",
default=1,
type=int,
help="How many copies of the provided file",
)
repeater_parser.add_argument(
"--file",
"-f",
required=True,
type=Path,
help="File to be copied",
)
repeater_parser.add_argument(
"-o",
"--output",
type=Path,
dest="output",
help="File (with .pdf suffix) to write the result. The directory needs to be existent.",
)