@@ -61,31 +61,21 @@ def process_rule(match):
6161 return re .sub (pattern , process_rule , css_content )
6262
6363
64- if __name__ == "__main__" :
65-
66- def main ():
67- parser = argparse .ArgumentParser (
68- description = "Add :host to each :root selector in a CSS file."
69- )
70- parser .add_argument ("css_file" , help = "Path to the CSS file to modify" )
71- args = parser .parse_args ()
64+ def main (argv ):
65+ parser = argparse .ArgumentParser (
66+ description = "Add :host to each :root selector in a CSS file."
67+ )
68+ parser .add_argument ("css_file" , help = "Path to the CSS file to modify" )
69+ args = parser .parse_args (argv [1 :])
7270
73- try :
74- with open (args .css_file , "r" ) as file :
75- css_content = file .read ()
71+ with open (args .css_file , "r" ) as file :
72+ css_content = file .read ()
7673
77- modified_content = add_host_to_root (css_content )
74+ modified_content = add_host_to_root (css_content )
7875
79- with open (args .css_file , "w" ) as file :
80- file .write (modified_content )
76+ with open (args .css_file , "w" ) as file :
77+ file .write (modified_content )
8178
82- print (f"Successfully updated { args .css_file } " )
83- return 0
84- except FileNotFoundError :
85- print (f"Error: File { args .css_file } not found." )
86- return 1
87- except Exception as e :
88- print (f"Error processing file: { e } " )
89- return 1
9079
91- sys .exit (main ())
80+ if __name__ == "__main__" :
81+ sys .exit (main (sys .argv ))
0 commit comments