@@ -49,7 +49,11 @@ enum Command {
4949 ///
5050 /// For example, use 'quickenv reload && eval "$(quickenv vars)"' to load the environment like
5151 /// direnv normally would.
52- Vars ,
52+ Vars {
53+ /// Quiet mode: print nothing if there is no .envrc
54+ #[ clap( long, short) ]
55+ quiet : bool ,
56+ } ,
5357 /// Create a new shim binary in ~/.quickenv/bin/.
5458 ///
5559 /// Executing that binary will run in the context of the nearest .envrc, as if it was activated
@@ -142,7 +146,7 @@ fn main_inner() -> Result<(), Error> {
142146
143147 match args. subcommand {
144148 Command :: Reload => command_reload ( ) ,
145- Command :: Vars => command_vars ( ) ,
149+ Command :: Vars { quiet } => command_vars ( quiet ) ,
146150 Command :: Shim { commands, yes } => command_shim ( commands, yes) ,
147151 Command :: Unshim { commands } => command_unshim ( commands) ,
148152 Command :: Exec { program_name, args } => command_exec ( program_name, args) ,
@@ -519,9 +523,16 @@ impl<'a> CheckUnshimmedCommands<'a> {
519523 }
520524}
521525
522- fn command_vars ( ) -> Result < ( ) , Error > {
526+ fn command_vars ( quiet : bool ) -> Result < ( ) , Error > {
523527 let quickenv_home = crate :: core:: get_quickenv_home ( ) ?;
524- let ctx = resolve_envrc_context ( & quickenv_home) ?;
528+
529+ let ctx = match resolve_envrc_context ( & quickenv_home) {
530+ Ok ( ctx) => ctx,
531+ Err ( core:: Error :: NoEnvrc ) if quiet => {
532+ return Ok ( ( ) ) ;
533+ }
534+ Err ( e) => return Err ( e. into ( ) ) ,
535+ } ;
525536
526537 if let Some ( envvars) = core:: get_envvars ( & ctx) ? {
527538 for ( k, v) in envvars {
@@ -531,6 +542,8 @@ fn command_vars() -> Result<(), Error> {
531542 io:: stdout ( ) . write_all ( b"\n " ) ?;
532543 }
533544
545+ Ok ( ( ) )
546+ } else if quiet {
534547 Ok ( ( ) )
535548 } else {
536549 log:: error!(
0 commit comments