sdoc 0.8.11

Framework for building custom CLIs around shell, scripts, and executables
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use workflow::Work;
use workflow::Instruction::SystemCommand;
use std::path::PathBuf;

pub fn execute_shell(shell: &String, args: &[String], directory: &PathBuf) -> Work {
    let command = format!("PATH=\"$PATH:{}\" {} {}", directory.display(), shell, quote_args(args));
    Work::instruction(SystemCommand(command, true))
}

fn quote_args(args: &[String]) -> String {
    let out_args : Vec<String> = args
        .iter()
        .map(|a| format!("'{}'", a))
        .collect();

    out_args.join(" ")
}