diff options
author | Cyril Plisko <cyril.plisko@mountall.com> | 2017-07-04 22:18:40 +0300 |
---|---|---|
committer | Cyril Plisko <cyril.plisko@mountall.com> | 2017-07-04 22:18:40 +0300 |
commit | dd8ec3b181ca8cc8d7fd1a705bcf6f2fc5a34aa2 (patch) | |
tree | 15e7d01ed86f8e1572bbb8e4af9c13da38af838a | |
parent | e6071702c9da214986f433878332f727301d8cf3 (diff) |
Add Pager::with_pager()
-rw-r--r-- | src/lib.rs | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -30,6 +30,21 @@ //! } //! ``` //! +//! Alternatively you can specify directly the desired pager command, exactly +//! as it would appear in PAGER environment variable. This is useful if you +//! need some specific pager and/or flags (like "more -r") and would like to +//! avoid forcing your consumers into modifying their existing PAGER +//! configuration just for your application. +//! +//! ```rust +//! extern crate pager; +//! use pager::Pager; +//! fn main() { +//! Pager::with_pager("more -r").setup(); +//! // The rest of your program goes here +//! } +//! ``` +//! //! If no suitable pager found `setup()` does nothing and your executable keeps //! running as usual. `Pager` cleans after itself and doesn't leak resources in //! case of setup failure. @@ -71,6 +86,15 @@ impl Pager { } } + /// Creates a new pager instance directly specifying the desired pager + pub fn with_pager(pager: &str) -> Self { + Pager { + pager: OsString::from(pager).into(), + env: None, + on: true, + } + } + /// Gives quick assessment of successful Pager setup pub fn is_on(&self) -> bool { self.on |