4444LICENSE_FILE_NAME = click .style ("license.lic" , blink = True , fg = 'blue' )
4545
4646SUCCESS_ANSI = click .style ('successfully' , fg = 'green' )
47+
4748INVALID_KEY_MSG = click .style ('Your encryption 🔑 is invalid.' , fg = 'red' )
4849
49- INVALID_EXPIRED_MSG = 'Expired before date must be less than expired after date.'
50+ INVALID_MAC_MSG = click .style ('{} is not a valid mac address.' , fg = 'red' )
51+
52+ INVALID_IPV4_MSG = click .style ('{} is not a valid ipv4 address.' , fg = 'red' )
53+
54+ INVALID_DATETIME_MSG = click .style ('Before date must be less than after date.' , fg = 'red' )
5055
5156FINISH_ENCRYPT_MSG = f"""
5257Encryption completed { SUCCESS_ANSI } .
@@ -96,7 +101,7 @@ class MacAddressParamType(click.ParamType):
96101 def convert (self , value , param , ctx ) -> str :
97102 value = click .STRING .convert (value , param , ctx )
98103 if not self .pattern .match (value ):
99- self .fail (f' { value } is not a valid mac address' , param , ctx )
104+ self .fail (INVALID_MAC_MSG . format ( value ) , param , ctx )
100105 return value
101106
102107 def get_metavar (self , param ):
@@ -114,7 +119,7 @@ def convert(self, value, param, ctx) -> str:
114119 try :
115120 return str (ipaddress .IPv4Address (value ))
116121 except ValueError :
117- self .fail (f' { value } is not a valid IPv4 Address' , param , ctx )
122+ self .fail (INVALID_IPV4_MSG . format ( value ) , param , ctx )
118123
119124 def get_metavar (self , param ):
120125 return '192.168.0.1'
@@ -155,7 +160,7 @@ def encrypt_command(ctx, pathname, replace, key, with_license, mac, ipv4, before
155160 click .echo (f'Your randomly encryption 🔑 is { click .style (key ,underline = True , fg = "yellow" )} ' )
156161
157162 if before > after :
158- ctx .fail (INVALID_EXPIRED_MSG )
163+ ctx .fail (INVALID_DATETIME_MSG )
159164
160165 path = Path (pathname )
161166
@@ -247,7 +252,7 @@ def generate_loader(ctx, key):
247252def generate_license (ctx , key , mac , ipv4 , before , after ):
248253 """Generate license file using specified key"""
249254 if before > after :
250- ctx .fail (INVALID_EXPIRED_MSG )
255+ ctx .fail (INVALID_DATETIME_MSG )
251256
252257 generate_license_file (key , Path (os .getcwd ()), after , before , mac , ipv4 )
253258 click .echo (FINISH_GENERATE_LICENSE_MSG )
0 commit comments