@@ -38,13 +38,22 @@ def cli(ctx, version): # pragma: no cover
3838 show_default = True ,
3939 help = "Add border to image file(s) with the border_color string" ,
4040)
41- def border (src_path , border_width , border_color ):
41+ @click .option (
42+ "-o" ,
43+ "--output" ,
44+ default = "" ,
45+ show_default = True ,
46+ type = str ,
47+ help = "Output file path. If skipped, use the current dir path" ,
48+ )
49+ def border (src_path , border_width , border_color , output ):
4250 options = {
4351 "src_path" : src_path ,
4452 "border_width" : border_width ,
4553 "border_color" : border_color ,
54+ "output" : output ,
4655 }
47- res = Main .add_border (options )
56+ res = Main .border (options )
4857 msg = MSG_OK if res else MSG_BAD
4958 click .secho (msg )
5059
@@ -57,15 +66,21 @@ def border(src_path, border_width, border_color):
5766 "src_path" ,
5867 required = True ,
5968)
60- def defaults (src_path ):
69+ @click .option (
70+ "-o" ,
71+ "--output" ,
72+ default = "" ,
73+ show_default = True ,
74+ type = str ,
75+ help = "Output file path. If skipped, use the current dir path" ,
76+ )
77+ def defaults (src_path , output ):
6178 """Do the default action on the image file(s):
6279 * Resize to 1280 pixels as the max length
6380 * Add a border: 5 pixel width, gray color
6481 * Auto-rotate if upside down or sideways
6582 """
66- options = {
67- "src_path" : src_path ,
68- }
83+ options = {"src_path" : src_path , "output" : output }
6984 res = Main .default_run (options )
7085 msg = MSG_OK if res else MSG_BAD
7186 click .secho (msg )
@@ -85,11 +100,16 @@ def defaults(src_path):
85100 type = click .IntRange (min = 0 ),
86101 help = "Resize image file(s) on original aspect ratio to the length. 0 - no resize" ,
87102)
88- def resize (src_path , length ):
89- options = {
90- "src_path" : src_path ,
91- "length" : length ,
92- }
103+ @click .option (
104+ "-o" ,
105+ "--output" ,
106+ default = "" ,
107+ show_default = True ,
108+ type = str ,
109+ help = "Output file path. If skipped, use the current dir path" ,
110+ )
111+ def resize (src_path , length , output ):
112+ options = {"src_path" : src_path , "length" : length , "output" : output }
93113 res = Main .resize (options )
94114 msg = MSG_OK if res else MSG_BAD
95115 click .secho (msg )
@@ -101,18 +121,27 @@ def resize(src_path, length):
101121 required = True ,
102122)
103123@click .option (
104- "-d " ,
105- "--degree " ,
124+ "-a " ,
125+ "--angle " ,
106126 is_flag = False ,
107127 default = 0 ,
108128 show_default = True ,
109129 type = click .IntRange (min = 0 ),
110- help = "Rotate image file(s) to the degree clock-wise. 0 - no rotate" ,
130+ help = "Rotate image file(s) to the clockwise angle. 0 - no rotate" ,
131+ )
132+ @click .option (
133+ "-o" ,
134+ "--output" ,
135+ default = "" ,
136+ show_default = True ,
137+ type = str ,
138+ help = "Output file path. If skipped, use the current dir path" ,
111139)
112- def rotate (src_path , degree ):
140+ def rotate (src_path , angle , output ):
113141 options = {
114142 "src_path" : src_path ,
115- "degree" : degree ,
143+ "angle" : angle ,
144+ "output" : output ,
116145 }
117146 res = Main .rotate (options )
118147 msg = MSG_OK if res else MSG_BAD
0 commit comments