use std::process::{Command, Stdio}; use bstr::{BString, ByteSlice, ByteVec}; use crate::{helper, Program}; /// The kind of helper program to use. #[derive(Debug, Clone, Eq, PartialEq)] pub enum Kind { /// The built-in `git credential` helper program, part of any `git` distribution. Builtin, /// A custom credentials helper, as identified just by the name with optional arguments ExternalName { /// The name like `foo` along with optional args, like `foo --arg --bar="a b"`, with arguments using `sh` shell quoting rules. /// The program executed will be `git-credential-foo` if `name_and_args` starts with `foo`. name_and_args: BString, }, /// A custom credentials helper, as identified just by the absolute path to the program and optional arguments. The program is executed through a shell. ExternalPath { /// The absolute path to the executable, like `/path/to/exe` along with optional args, like `/path/to/exe --arg --bar="a b"`, with arguments using `sh` /// shell quoting rules. path_and_args: BString, }, /// A script to execute with `sh`. ExternalShellScript(BString), } /// Initialization impl Program { /// Create a new program of the given `kind`. pub fn from_kind(kind: Kind) -> Self { Program { kind, child: None, stderr: true, } } /// Parse the given input as per the custom helper definition, supporting `!