Bookmark name as hostname for cli args (#111)

bookmark name as hostname for cli args
This commit is contained in:
Christian Visintin
2022-05-03 11:54:48 +02:00
committed by GitHub
parent f094979ddb
commit e0d8b80cdf
21 changed files with 629 additions and 292 deletions

View File

@@ -33,6 +33,7 @@ pub mod parser;
pub mod path;
pub mod random;
pub mod string;
pub mod tty;
pub mod ui;
#[cfg(test)]

36
src/utils/tty.rs Normal file
View File

@@ -0,0 +1,36 @@
//! ## Utils
//!
//! `Utils` implements utilities functions to work with layouts
/**
* MIT License
*
* termscp - Copyright (c) 2022 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/// Read a secret from tty with customisable prompt
pub fn read_secret_from_tty(prompt: &str) -> std::io::Result<Option<String>> {
match rpassword::read_password_from_tty(Some(prompt)) {
Ok(p) if p.is_empty() => Ok(None),
Ok(p) => Ok(Some(p)),
Err(err) => Err(err),
}
}