-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add info command to display key information (#461)
- Loading branch information
1 parent
23535d2
commit 6f7b2e4
Showing
17 changed files
with
546 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# info command (Winget-Create) | ||
|
||
The **info** command of the [Winget-Create](../README.md) tool is used to show useful information about the client. This information includes the location of the settings file, the local installer cache (download directory) and the logs directory. It also offers links to external resources like the GitHub repository and privacy statement. | ||
|
||
## Usage | ||
|
||
* Display information related to the client: `wingetcreate.exe info` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
namespace Microsoft.WingetCreateCLI.Commands | ||
{ | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using CommandLine; | ||
using Microsoft.WingetCreateCLI.Logging; | ||
using Microsoft.WingetCreateCLI.Properties; | ||
using Microsoft.WingetCreateCLI.Telemetry; | ||
using Microsoft.WingetCreateCLI.Telemetry.Events; | ||
using Microsoft.WingetCreateCore; | ||
using Microsoft.WingetCreateCore.Common; | ||
|
||
/// <summary> | ||
/// Info command to display general information regarding the tool. | ||
/// </summary> | ||
[Verb("info", HelpText = "InfoCommand_HelpText", ResourceType = typeof(Resources))] | ||
public class InfoCommand : BaseCommand | ||
{ | ||
/// <summary> | ||
/// Executes the info command flow. | ||
/// </summary> | ||
/// <returns>Boolean representing success or fail of the command.</returns> | ||
public override async Task<bool> Execute() | ||
{ | ||
CommandExecutedEvent commandEvent = new CommandExecutedEvent | ||
{ | ||
Command = nameof(InfoCommand), | ||
}; | ||
|
||
DisplayApplicationHeaderAndCopyright(); | ||
Console.WriteLine(); | ||
DisplaySystemInformation(); | ||
Console.WriteLine(); | ||
DisplayInfoTable(); | ||
|
||
TelemetryManager.Log.WriteEvent(commandEvent); | ||
return await Task.FromResult(commandEvent.IsSuccessful = true); | ||
} | ||
|
||
private static void DisplayApplicationHeaderAndCopyright() | ||
{ | ||
Console.WriteLine(string.Format( | ||
Resources.Heading, | ||
Utils.GetEntryAssemblyVersion()) + | ||
Environment.NewLine + | ||
Constants.MicrosoftCopyright); | ||
} | ||
|
||
private static void DisplaySystemInformation() | ||
{ | ||
Logger.DebugLocalized(nameof(Resources.OperatingSystem_Info), Environment.OSVersion.VersionString); | ||
Logger.DebugLocalized(nameof(Resources.SystemArchitecture_Info), System.Runtime.InteropServices.RuntimeInformation.OSArchitecture); | ||
} | ||
|
||
private static void DisplayInfoTable() | ||
{ | ||
string logsdirectory = Common.GetPathForDisplay(Path.Combine(Common.LocalAppStatePath, Constants.DiagnosticOutputDirectoryFolderName), UserSettings.AnonymizePaths); | ||
string settingsDirectory = Common.GetPathForDisplay(UserSettings.SettingsJsonPath, UserSettings.AnonymizePaths); | ||
string installerCacheDirectory = Common.GetPathForDisplay(PackageParser.InstallerDownloadPath, UserSettings.AnonymizePaths); | ||
|
||
new TableOutput(Resources.WingetCreateDirectories_Heading, Resources.Path_Heading) | ||
.AddRow(Resources.Logs_Heading, logsdirectory) | ||
.AddRow(Resources.UserSettings_Heading, settingsDirectory) | ||
.AddRow(Resources.InstallerCache_Heading, installerCacheDirectory) | ||
.Print(); | ||
|
||
Console.WriteLine(); | ||
|
||
new TableOutput(Resources.Links_Heading, string.Empty) | ||
.AddRow(Resources.PrivacyStatement_Heading, Constants.PrivacyStatementUrl) | ||
.AddRow(Resources.LicenseAgreement_Heading, Constants.LicenseUrl) | ||
.AddRow(Resources.ThirdPartyNotices_Heading, Constants.ThirdPartyNoticeUrl) | ||
.AddRow(Resources.Homepage_Heading, Constants.HomePageUrl) | ||
.Print(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.