@@ -35,7 +35,6 @@ def run(argv):
35
35
description = "An OpenType table diff tool for fonts."
36
36
)
37
37
parser .add_argument ("--version" , action = "version" , version = f"fdiff v{ __version__ } " )
38
- parser .add_argument ("--git" , type = str , nargs = 7 , help = "Act as a diff driver for git (takes 7 parameters)" )
39
38
parser .add_argument (
40
39
"-c" ,
41
40
"--color" ,
@@ -65,15 +64,23 @@ def run(argv):
65
64
"--nomp" , action = "store_true" , help = "Do not use multi process optimizations"
66
65
)
67
66
parser .add_argument ("--external" , type = str , help = "Run external diff tool command" )
67
+
68
+ parser .add_argument ("--git" , type = str , nargs = 7 , help = "Act as a diff driver for git (takes 7 parameters)" )
68
69
# parser.add_argument("PREFILE", help="Font file path/URL 1")
69
70
# parser.add_argument("POSTFILE", help="Font file path/URL 2")
70
71
71
- args = parser .parse_args (argv )
72
+ args , positionals = parser .parse_known_args (argv )
72
73
74
+ inputs = argparse .Namespace ()
73
75
if args .git :
74
- print (args .git )
75
- args .PREFILE = args .git [1 ]
76
- args .POSTFILE = args .git [4 ]
76
+ inputs .PREFILE = args .git [1 ]
77
+ inputs .POSTFILE = args .git [4 ]
78
+ else :
79
+ inputparser = argparse .ArgumentParser ()
80
+ inputparser .add_argument ("PREFILE" , help = "Font file path/URL 1" )
81
+ inputparser .add_argument ("POSTFILE" , help = "Font file path/URL 2" )
82
+ inputparser .parse_args (positionals , namespace = inputs )
83
+
77
84
78
85
# /////////////////////////////////////////////////////////
79
86
#
@@ -85,14 +92,14 @@ def run(argv):
85
92
# File path argument validations
86
93
# -------------------------------
87
94
88
- if not args .PREFILE .startswith ("http" ) and not file_exists (args .PREFILE ):
95
+ if not inputs .PREFILE .startswith ("http" ) and not file_exists (inputs .PREFILE ):
89
96
sys .stderr .write (
90
- f"[*] ERROR: The file path '{ args .PREFILE } ' can not be found.{ os .linesep } "
97
+ f"[*] ERROR: The file path '{ inputs .PREFILE } ' can not be found.{ os .linesep } "
91
98
)
92
99
sys .exit (1 )
93
- if not args .POSTFILE .startswith ("http" ) and not file_exists (args .POSTFILE ):
100
+ if not inputs .POSTFILE .startswith ("http" ) and not file_exists (inputs .POSTFILE ):
94
101
sys .stderr .write (
95
- f"[*] ERROR: The file path '{ args .POSTFILE } ' can not be found.{ os .linesep } "
102
+ f"[*] ERROR: The file path '{ inputs .POSTFILE } ' can not be found.{ os .linesep } "
96
103
)
97
104
sys .exit (1 )
98
105
@@ -134,8 +141,8 @@ def run(argv):
134
141
try :
135
142
diff = external_diff (
136
143
args .external ,
137
- args .PREFILE ,
138
- args .POSTFILE ,
144
+ inputs .PREFILE ,
145
+ inputs .POSTFILE ,
139
146
include_tables = include_list ,
140
147
exclude_tables = exclude_list ,
141
148
use_multiprocess = use_mp ,
@@ -160,8 +167,8 @@ def run(argv):
160
167
# perform the unified diff analysis
161
168
try :
162
169
diff = u_diff (
163
- args .PREFILE ,
164
- args .POSTFILE ,
170
+ inputs .PREFILE ,
171
+ inputs .POSTFILE ,
165
172
context_lines = args .lines ,
166
173
include_tables = include_list ,
167
174
exclude_tables = exclude_list ,
0 commit comments