@@ -54,6 +54,10 @@ struct Args {
5454 /// Trust proxies from these CIDR ranges for X-Forwarded-For parsing
5555 #[ clap( long = "trust-proxy" , value_name = "CIDR" ) ]
5656 trust_proxies : Vec < ipnet:: IpNet > ,
57+
58+ /// Set NU_LIB_DIRS for module resolution (can be repeated)
59+ #[ clap( short = 'I' , long = "include-path" , global = true , value_name = "PATH" ) ]
60+ include_paths : Vec < PathBuf > ,
5761}
5862
5963#[ derive( Clone , Debug , Default , clap:: ValueEnum ) ]
@@ -81,9 +85,11 @@ enum Command {
8185fn create_base_engine (
8286 interrupt : Arc < AtomicBool > ,
8387 plugins : & [ PathBuf ] ,
88+ include_paths : & [ PathBuf ] ,
8489) -> Result < Engine , Box < dyn std:: error:: Error + Send + Sync > > {
8590 let mut engine = Engine :: new ( ) ?;
8691 engine. add_custom_commands ( ) ?;
92+ engine. set_lib_dirs ( include_paths) ?;
8793
8894 // Load plugins
8995 for plugin_path in plugins {
@@ -386,6 +392,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
386392
387393 let mut engine = Engine :: new ( ) ?;
388394 engine. add_custom_commands ( ) ?;
395+ engine. set_lib_dirs ( & args. include_paths ) ?;
389396
390397 for plugin_path in & args. plugins {
391398 engine. load_plugin ( plugin_path) ?;
@@ -411,7 +418,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
411418 let read_stdin = closure == "-" ;
412419
413420 // Create base engine with commands, signals, and plugins
414- let base_engine = create_base_engine ( interrupt. clone ( ) , & args. plugins ) ?;
421+ let base_engine = create_base_engine ( interrupt. clone ( ) , & args. plugins , & args . include_paths ) ?;
415422
416423 // Create channel for scripts
417424 let ( tx, rx) = mpsc:: channel :: < String > ( 1 ) ;
0 commit comments