ceph_async/
utils.rs

1// Copyright 2017 LambdaStack All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::io::Result;
16
17use std::process::{Command, Output};
18
19/// run_cli - pass in a String of a normal command line
20///
21/// The function will split the options into words to supply to the low_level
22/// std::process::Command
23/// which returns Result<(Output)>
24/// # Example
25///
26/// ```
27/// use ceph::utils::run_cli;
28/// run_cli("ps aux");
29/// ```
30
31// NOTE: Add Into so a "" can also be passed in...
32pub fn run_cli(cmd_line: &str) -> Result<Output> {
33    let output = Command::new("sh").arg("-c").arg(cmd_line).output()?;
34    Ok(output)
35}