@@ -27,6 +27,7 @@ use selenium_manager::jre::ensure_jre;
2727use selenium_manager:: lock:: clear_lock_if_required;
2828use selenium_manager:: logger:: { BROWSER_PATH , DRIVER_PATH , Logger } ;
2929use selenium_manager:: metadata:: clear_metadata;
30+ use selenium_manager:: rules:: write_rules_file;
3031use selenium_manager:: skills:: write_skills_file;
3132use selenium_manager:: { REQUEST_TIMEOUT_SEC , SM_BETA_LABEL } ;
3233use selenium_manager:: {
@@ -162,6 +163,10 @@ struct Cli {
162163 /// Add a skills file with Selenium best practices to the repository
163164 #[ clap( long, value_name = "FILE_NAME" , num_args = 0 ..=1 , default_missing_value = "" ) ]
164165 init_skills : Option < String > ,
166+
167+ /// Add a rules file with Selenium guidance for LLM coding assistants to the repository
168+ #[ clap( long, value_name = "FILE_NAME" , num_args = 0 ..=1 , default_missing_value = "" ) ]
169+ init_rules : Option < String > ,
165170}
166171
167172fn main ( ) {
@@ -189,6 +194,23 @@ fn main() {
189194 flush_and_exit ( OK , & log, None ) ;
190195 }
191196
197+ if let Some ( mut rules_file) = cli. init_rules {
198+ if rules_file. is_empty ( ) {
199+ let default_path = Path :: new ( "rules" ) . join ( "selenium.md" ) ;
200+ if default_path. exists ( ) {
201+ rules_file = "selenium-rules.md" . to_string ( ) ;
202+ } else {
203+ rules_file = default_path. to_string_lossy ( ) . to_string ( ) ;
204+ }
205+ }
206+ if let Err ( err) = write_rules_file ( Path :: new ( & rules_file) , & log) {
207+ log. error ( format ! ( "Error creating {}: {}" , rules_file, err) ) ;
208+ flush_and_exit ( DATAERR , & log, Some ( err) ) ;
209+ }
210+ log. info ( format ! ( "{} file successfully created" , rules_file) ) ;
211+ flush_and_exit ( OK , & log, None ) ;
212+ }
213+
192214 let cache_path =
193215 StringKey ( vec ! [ CACHE_PATH_KEY ] , & cli. cache_path . unwrap_or_default ( ) ) . get_value ( ) ;
194216 let grid = cli. grid ;
0 commit comments