173173//!
174174//! ```no_run
175175//! # use xshell::{Shell, cmd}; let sh = Shell::new().unwrap();
176- //! let dry_run = if sh.env_var ("CI").is_ok() { None } else { Some("--dry-run") };
176+ //! let dry_run = if sh.var ("CI").is_ok() { None } else { Some("--dry-run") };
177177//! cmd!(sh, "cargo publish {dry_run...}").run_echo()?;
178178//! # Ok::<(), xshell::Error>(())
179179//! ```
203203//!
204204//! cmd!(sh, "git tag {version}").run_echo()?;
205205//!
206- //! let dry_run = if sh.env_var ("CI").is_ok() { None } else { Some("--dry-run") };
206+ //! let dry_run = if sh.var ("CI").is_ok() { None } else { Some("--dry-run") };
207207//! cmd!(sh, "cargo publish {dry_run...}").run()?;
208208//!
209209//! Ok(())
217217//!
218218//! ## Maintenance
219219//!
220- //! Minimum Supported Rust Version: 1.63.0. MSRV bump is not considered semver breaking. MSRV is
221- //! updated conservatively.
220+ //! MSRV bump is not considered semver breaking. MSRV is updated conservatively.
222221//!
223222//! The crate isn't comprehensive yet, but this is a goal. You are hereby encouraged to submit PRs
224223//! with missing functionality!
@@ -426,10 +425,10 @@ impl Shell {
426425 ///
427426 /// Environment of the [`Shell`] affects all commands spawned via this
428427 /// shell.
429- pub fn env_var ( & self , key : impl AsRef < OsStr > ) -> Result < String > {
428+ pub fn var ( & self , key : impl AsRef < OsStr > ) -> Result < String > {
430429 fn inner ( sh : & Shell , key : & OsStr ) -> Result < String > {
431430 let env_os = sh
432- . env_var_os ( key)
431+ . var_os ( key)
433432 . ok_or ( VarError :: NotPresent )
434433 . map_err ( |err| Error :: new_var ( err, key. to_os_string ( ) ) ) ?;
435434 env_os
@@ -444,7 +443,7 @@ impl Shell {
444443 ///
445444 /// Environment of the [`Shell`] affects all commands spawned via this
446445 /// shell.
447- pub fn env_var_os ( & self , key : impl AsRef < OsStr > ) -> Option < OsString > {
446+ pub fn var_os ( & self , key : impl AsRef < OsStr > ) -> Option < OsString > {
448447 fn inner ( sh : & Shell , key : & OsStr ) -> Option < OsString > {
449448 sh. env . get ( key) . map ( OsString :: from) . or_else ( || env:: var_os ( key) )
450449 }
@@ -457,7 +456,7 @@ impl Shell {
457456 ///
458457 /// Environment of the [`Shell`] affects all commands spawned via this
459458 /// shell.
460- pub fn env_vars_os ( & self ) -> HashMap < OsString , OsString > {
459+ pub fn vars_os ( & self ) -> HashMap < OsString , OsString > {
461460 let mut result: HashMap < OsString , OsString > = Default :: default ( ) ;
462461 result. extend ( env:: vars_os ( ) ) ;
463462 result. extend ( self . env . iter ( ) . map ( |( k, v) | ( OsString :: from ( k) , OsString :: from ( v) ) ) ) ;
@@ -467,7 +466,7 @@ impl Shell {
467466 /// Sets the value of `key` environment variable for this [`Shell`] to `value`.
468467 ///
469468 /// Note that this doesn't affect [`std::env::var`].
470- pub fn set_env_var ( & mut self , key : impl AsRef < OsStr > , value : impl AsRef < OsStr > ) {
469+ pub fn set_var ( & mut self , key : impl AsRef < OsStr > , value : impl AsRef < OsStr > ) {
471470 fn inner ( sh : & mut Shell , key : & OsStr , value : & OsStr ) {
472471 Arc :: make_mut ( & mut sh. env ) . insert ( key. into ( ) , value. into ( ) ) ;
473472 }
@@ -477,7 +476,7 @@ impl Shell {
477476 /// Returns a new [`Shell`] with environmental variable `key` set to `value`.
478477 ///
479478 /// Note that this doesn't affect [`std::env::var`].
480- pub fn with_env_var ( & self , key : impl AsRef < OsStr > , value : impl AsRef < OsStr > ) -> Shell {
479+ pub fn with_var ( & self , key : impl AsRef < OsStr > , value : impl AsRef < OsStr > ) -> Shell {
481480 fn inner ( sh : & Shell , key : & OsStr , value : & OsStr ) -> Shell {
482481 let mut env = Arc :: clone ( & sh. env ) ;
483482 Arc :: make_mut ( & mut env) . insert ( key. into ( ) , value. into ( ) ) ;
@@ -523,11 +522,7 @@ impl Shell {
523522
524523 /// Creates a `dst` file with the same contents as `src`
525524 #[ doc( alias = "cp" ) ]
526- pub fn copy_file_to_path (
527- & self ,
528- src_file : impl AsRef < Path > ,
529- dst_file : impl AsRef < Path > ,
530- ) -> Result < ( ) > {
525+ pub fn copy_file ( & self , src_file : impl AsRef < Path > , dst_file : impl AsRef < Path > ) -> Result < ( ) > {
531526 fn inner ( sh : & Shell , src : & Path , dst : & Path ) -> Result < ( ) > {
532527 let src = sh. path ( src) ;
533528 let dst = sh. path ( dst) ;
@@ -554,7 +549,7 @@ impl Shell {
554549 let Some ( file_name) = src. file_name ( ) else {
555550 return Err ( Error :: new_copy_file ( io:: ErrorKind :: InvalidData . into ( ) , src, dst) ) ;
556551 } ;
557- sh. copy_file_to_path ( & src, & dst. join ( file_name) )
552+ sh. copy_file ( & src, & dst. join ( file_name) )
558553 }
559554 inner ( self , src_file. as_ref ( ) , dst_dir. as_ref ( ) )
560555 }
0 commit comments