Skip to main content

program_and_subcommand

Function program_and_subcommand 

Source
pub fn program_and_subcommand(words: &[&str]) -> Option<String>
Expand description

What: The program and subcommand of a command line, with every other argument left out. Why: Arguments can hold secrets (-c http.extraHeader=...), and the notice repeats at an interval into logs, so only the program’s name and the subcommand are shown. Global options are skipped to find the subcommand.

In TS you’d write (pseudocode):

`${basename(argv[0])} ${argv.slice(1).find((word, i) => !word.startsWith('-') && !valueOptions.includes(argv[i]))}`