Changeset 85780 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Aug 14, 2020 9:29:46 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 139936
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r85778 r85780 261 261 HRESULT showBandwidthGroups(ComPtr<IBandwidthControl> &bwCtrl, 262 262 VMINFO_DETAILS details); 263 void outputMachineReadableString(const char *pszName, const char *pszValue); 264 void outputMachineReadableString(const char *pszName, com::Bstr const *pbstrValue); 265 void outputMachineReadableBool(const char *pszName, BOOL const *pfValue); 266 void outputMachineReadableBool(const char *pszName, bool const *pfValue); 267 void outputMachineReadableULong(const char *pszName, ULONG *uValue); 268 void outputMachineReadableLong64(const char *pszName, LONG64 *uValue); 263 269 264 270 /* VBoxManageList.cpp */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r85779 r85780 231 231 * @param pszValue The value. 232 232 */ 233 staticvoid outputMachineReadableString(const char *pszName, const char *pszValue)233 void outputMachineReadableString(const char *pszName, const char *pszValue) 234 234 { 235 235 Assert(strpbrk(pszName, "\"\\") == NULL); … … 268 268 * @param pbstrValue The value. 269 269 */ 270 staticvoid outputMachineReadableString(const char *pszName, Bstr const *pbstrValue)270 void outputMachineReadableString(const char *pszName, Bstr const *pbstrValue) 271 271 { 272 272 com::Utf8Str strValue(*pbstrValue); 273 273 outputMachineReadableString(pszName, strValue.c_str()); 274 274 } 275 276 277 /** 278 * Machine readable outputting of a boolean value. 279 */ 280 void outputMachineReadableBool(const char *pszName, BOOL const *pfValue) 281 { 282 RTPrintf("%s=\"%s\"\n", pszName, *pfValue ? "on" : "off"); 283 } 284 285 286 /** 287 * Machine readable outputting of a boolean value. 288 */ 289 void outputMachineReadableBool(const char *pszName, bool const *pfValue) 290 { 291 RTPrintf("%s=\"%s\"\n", pszName, *pfValue ? "on" : "off"); 292 } 293 294 295 /** 296 * Machine readable outputting of a ULONG value. 297 */ 298 void outputMachineReadableULong(const char *pszName, ULONG *puValue) 299 { 300 RTPrintf("%s=\"%u\"\n", pszName, *puValue); 301 } 302 303 304 /** 305 * Machine readable outputting of a LONG64 value. 306 */ 307 void outputMachineReadableLong64(const char *pszName, LONG64 *puValue) 308 { 309 RTPrintf("%s=\"%llu\"\n", pszName, *puValue); 310 } 311 275 312 276 313 /** -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageUpdateCheck.cpp
r85778 r85780 51 51 static const RTGETOPTDEF s_aOptions[] = 52 52 { 53 { "-- verbose", 'v',RTGETOPT_REQ_NOTHING }53 { "--machine-readable", 'm', RTGETOPT_REQ_NOTHING } 54 54 }; 55 55 RTGETOPTSTATE GetState; … … 57 57 AssertRCReturn(vrc, RTEXITCODE_INIT); 58 58 59 bool fMachineReadable = false; 60 59 61 int c; 60 62 RTGETOPTUNION ValueUnion; … … 63 65 switch (c) 64 66 { 67 case 'm': 68 fMachineReadable = true; 69 break; 70 65 71 default: 66 72 return errorGetOpt(c, &ValueUnion); … … 76 82 BOOL fVBoxUpdateEnabled; 77 83 CHECK_ERROR2I_RET(pSystemProperties, COMGETTER(VBoxUpdateEnabled)(&fVBoxUpdateEnabled), RTEXITCODE_FAILURE); 78 RTPrintf("Enabled: %s\n", fVBoxUpdateEnabled ? "yes" : "no"); 84 if (fMachineReadable) 85 outputMachineReadableBool("enabled", &fVBoxUpdateEnabled); 86 else 87 RTPrintf("Enabled: %s\n", fVBoxUpdateEnabled ? "yes" : "no"); 79 88 80 89 ULONG cVBoxUpdateCount; 81 90 CHECK_ERROR2I_RET(pSystemProperties, COMGETTER(VBoxUpdateCount)(&cVBoxUpdateCount), RTEXITCODE_FAILURE); 82 RTPrintf("Count: %u\n", cVBoxUpdateCount); 83 84 ULONG uVBoxUpdateFrequency; 85 CHECK_ERROR2I_RET(pSystemProperties, COMGETTER(VBoxUpdateFrequency)(&uVBoxUpdateFrequency), RTEXITCODE_FAILURE); 86 if (uVBoxUpdateFrequency == 0) 87 RTPrintf("Frequency: never\n"); 88 else if (uVBoxUpdateFrequency == 1) 91 if (fMachineReadable) 92 outputMachineReadableULong("count", &cVBoxUpdateCount); 93 else 94 RTPrintf("Count: %u\n", cVBoxUpdateCount); 95 96 ULONG cDaysFrequencey; 97 CHECK_ERROR2I_RET(pSystemProperties, COMGETTER(VBoxUpdateFrequency)(&cDaysFrequencey), RTEXITCODE_FAILURE); 98 if (fMachineReadable) 99 outputMachineReadableULong("frequency", &cDaysFrequencey); 100 else if (cDaysFrequencey == 0) 101 RTPrintf("Frequency: never\n"); /** @todo r=bird: Two inconsistencies here. HostUpdateImpl.cpp code will indicate the need for updating if no last-check-date. modifysettings cannot set it to zero (I added the error message, you just skipped setting it originally). */ 102 else if (cDaysFrequencey == 1) 89 103 RTPrintf("Frequency: every day\n"); 90 104 else 91 RTPrintf("Frequency: every %u days\n", uVBoxUpdateFrequency);105 RTPrintf("Frequency: every %u days\n", cDaysFrequencey); 92 106 93 107 VBoxUpdateTarget_T enmVBoxUpdateTarget; 94 108 CHECK_ERROR2I_RET(pSystemProperties, COMGETTER(VBoxUpdateTarget)(&enmVBoxUpdateTarget), RTEXITCODE_FAILURE); 95 109 const char *psz; 110 const char *pszMachine; 96 111 switch (enmVBoxUpdateTarget) 97 112 { 98 113 case VBoxUpdateTarget_Stable: 99 114 psz = "Stable - new minor and maintenance releases"; 115 pszMachine = "stable"; 100 116 break; 101 117 case VBoxUpdateTarget_AllReleases: 102 118 psz = "All releases - new minor, maintenance, and major releases"; 119 pszMachine = "all-releases"; 103 120 break; 104 121 case VBoxUpdateTarget_WithBetas: 105 122 psz = "With Betas - new minor, maintenance, major, and beta releases"; 123 pszMachine = "with-betas"; 106 124 break; 107 125 default: 126 AssertFailed(); 108 127 psz = "Unset"; 128 pszMachine = "invalid"; 109 129 break; 110 130 } 111 RTPrintf("Target: %s\n", psz); 112 113 Bstr strVBoxUpdateLastCheckDate; 114 CHECK_ERROR2I_RET(pSystemProperties, COMGETTER(VBoxUpdateLastCheckDate)(strVBoxUpdateLastCheckDate.asOutParam()), 131 if (fMachineReadable) 132 outputMachineReadableString("target", pszMachine); 133 else 134 RTPrintf("Target: %s\n", psz); 135 136 Bstr bstrLastCheckDate; 137 CHECK_ERROR2I_RET(pSystemProperties, COMGETTER(VBoxUpdateLastCheckDate)(bstrLastCheckDate.asOutParam()), 115 138 RTEXITCODE_FAILURE); 116 if (!strVBoxUpdateLastCheckDate.isEmpty()) 117 RTPrintf("Last Check Date: %ls\n", strVBoxUpdateLastCheckDate.raw()); 139 if (fMachineReadable) 140 outputMachineReadableString("last-check-date", &bstrLastCheckDate); 141 else if (bstrLastCheckDate.isNotEmpty()) 142 RTPrintf("Last Check Date: %ls\n", bstrLastCheckDate.raw()); 118 143 119 144 return RTEXITCODE_SUCCESS; … … 220 245 static const RTGETOPTDEF s_aOptions[] = 221 246 { 222 { "-- verbose", 'v',RTGETOPT_REQ_NOTHING }247 { "--machine-readable", 'm', RTGETOPT_REQ_NOTHING } 223 248 }; 224 249 RTGETOPTSTATE GetState; … … 226 251 AssertRCReturn(vrc, RTEXITCODE_INIT); 227 252 253 bool fMachineReadable = false; 254 228 255 int c; 229 256 RTGETOPTUNION ValueUnion; … … 232 259 switch (c) 233 260 { 261 case 'm': 262 fMachineReadable = true; 263 break; 264 234 265 default: 235 266 return errorGetOpt(c, &ValueUnion); … … 277 308 CHECK_ERROR2I_RET(pHostUpdate, COMGETTER(UpdateResponse)(&fUpdateNeeded), RTEXITCODE_FAILURE); 278 309 279 if (!fUpdateNeeded) 280 RTPrintf("You are already running the most recent version of VirtualBox.\n"); 281 else 310 if (fMachineReadable) 311 outputMachineReadableBool("update-needed", &fUpdateNeeded); 312 313 if (fUpdateNeeded) 282 314 { 283 315 Bstr bstrUpdateVersion; … … 286 318 CHECK_ERROR2I_RET(pHostUpdate, COMGETTER(UpdateURL)(bstrUpdateURL.asOutParam()), RTEXITCODE_FAILURE); 287 319 288 RTPrintf("A new version of VirtualBox has been released! Version %ls is available at virtualbox.org.\n" 289 "You can download this version here: %ls\n", bstrUpdateVersion.raw(), bstrUpdateURL.raw()); 290 } 320 if (fMachineReadable) 321 RTPrintf("A new version of VirtualBox has been released! Version %ls is available at virtualbox.org.\n" 322 "You can download this version here: %ls\n", bstrUpdateVersion.raw(), bstrUpdateURL.raw()); 323 else 324 { 325 outputMachineReadableString("update-version", &bstrUpdateVersion); 326 outputMachineReadableString("update-url", &bstrUpdateURL); 327 } 328 } 329 else if (!fMachineReadable) 330 RTPrintf("You are already running the most recent version of VirtualBox.\n"); 291 331 292 332 return RTEXITCODE_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.