MCPcopy Create free account
hub / github.com/MITK/MITK / FormatCommand

Function FormatCommand

Modules/PythonInstaller/src/QmitkPipInstaller.cpp:27–44  ·  view source on GitHub ↗

Quote arguments containing whitespace so the logged command line is copy-pasteable into a shell for reproduction.

Source from the content-addressed store, hash-verified

25 // Quote arguments containing whitespace so the logged command line is
26 // copy-pasteable into a shell for reproduction.
27 QString FormatCommand(const QString& program, const QStringList& args)
28 {
29 const auto quote = [](const QString& token) {
30 return token.contains(QChar::Space) ? '"' + token + '"' : token;
31 };
32
33 QString result = quote(program);
34 for (const auto& arg : args)
35 {
36 result += ' ';
37 result += quote(arg);
38 }
39 // Redact credentials from URLs: "://user:password@" -> "://****:****@"
40 static QRegularExpression credentialPattern("://[^/@]+:[^/@]+@");
41 result.replace(credentialPattern, "://****:****@");
42
43 return result;
44 }
45
46 // Canonicalize a package name per PEP 503: lowercase, and treat runs of
47 // '-', '_', '.' as a single '-'. Used to match resolved package names

Callers 5

BeginVirtualEnvPhaseMethod · 0.85
StartPipUpgradeMethod · 0.85
StartResolveGroupMethod · 0.85
StartInstallPackageMethod · 0.85
StartPostInstallStepMethod · 0.85

Calls 1

containsMethod · 0.80

Tested by

no test coverage detected