Skip to content

Commit

Permalink
Modifying Update command to update ProductCode for MSIs (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
palenshus authored Jun 7, 2021
1 parent 8e6ec72 commit 4e44a92
Show file tree
Hide file tree
Showing 3 changed files with 498 additions and 456 deletions.
8 changes: 4 additions & 4 deletions doc/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The **update** command of the [Winget-Create](../README.md) tool is designed to

## Usage

`WingetCreateCLI.exe update [<url>] [\<options>]`
`WingetCreateCLI.exe update <id> [-u <url>] [-v <version>] [-s] [-t <token>] [-o <output directory>]`

The **update** command can be called with the optional URL. If the URL is provided, **Winget-Create** will download the installer as it begins. If the URL is not included, the user will need to add it when prompted.

Expand All @@ -15,9 +15,9 @@ The following arguments are available:

| Argument | Description |
|--------------|-------------|
| **-i, --id** | Required. Package identifier used to lookup the existing manifest on the Windows Package Manager repo. Id is case-sensitive.
| **-v, --version** | Version to be used when updating the package version field.
| **id** | Required. Package identifier used to lookup the existing manifest on the Windows Package Manager repo.
| **-u, --url** | Installer Url used to extract relevant metadata for generating a manifest
| **-v, --version** | Version to be used when updating the package version field.
| **-o, --out** | The output directory where the newly created manifests will be saved locally
| **-s, --submit** | Boolean value for submitting to the Windows Package Manager repo. If true, updated manifest will be submitted directly using the provided GitHub Token
| **-t, --token** | GitHub personal access token used for direct submission to the Windows Package Manager repo. If no token is provided, tool will prompt for GitHub login credentials.
Expand All @@ -28,7 +28,7 @@ The update command allows you to quickly and easily update your manifest and sub
1) publish your installer to known URL
2) call the WingetCreateCLI.exe

`WingetCreateCLI.exe update --id <PackageIdentifier> --url <InstallerUrl> --token <token> --version <version>`
`WingetCreateCLI.exe update <PackageIdentifier> --url <InstallerUrl> --token <token> --version <version>`

### PackageIdentifier

Expand Down
39 changes: 36 additions & 3 deletions src/WingetCreateCLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Microsoft.WingetCreateCLI
{
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using CommandLine;
using CommandLine.Text;
Expand Down Expand Up @@ -37,7 +38,7 @@ private static async Task<int> Main(string[] args)
BaseCommand command = parserResult.MapResult(c => c as BaseCommand, err => null);
if (command == null)
{
DisplayHelp(parserResult);
DisplayHelp(parserResult as NotParsed<object>);
return 1;
}

Expand All @@ -60,7 +61,7 @@ private static async Task<int> Main(string[] args)
}
}

private static int DisplayHelp(ParserResult<object> result)
private static void DisplayHelp(NotParsed<object> result)
{
var helpText = HelpText.AutoBuild(
result,
Expand All @@ -81,7 +82,39 @@ private static int DisplayHelp(ParserResult<object> result)
e => e,
verbsIndex: true);
Console.WriteLine(helpText);
return -1;
Console.WriteLine();

foreach (var error in result.Errors)
{
if (error is SetValueExceptionError sve)
{
Utils.WriteLineColored(ConsoleColor.Red, $"{sve.NameInfo.LongName}: {sve.Exception.Message}");
if (sve.Exception.InnerException != null)
{
Utils.WriteLineColored(ConsoleColor.Red, $"{sve.Exception.InnerException.Message}");
}

if (sve.Value is IEnumerable<object> list)
{
foreach (var val in list)
{
Utils.WriteLineColored(ConsoleColor.Red, $"\t{val}");
}
}
else
{
Utils.WriteLineColored(ConsoleColor.Red, $"\t{sve.Value}");
}
}
else if (error is UnknownOptionError uoe)
{
Utils.WriteLineColored(ConsoleColor.Red, $"Unknown option: {uoe.Token}");
}
else
{
Utils.WriteLineColored(ConsoleColor.Red, $"Command line parsing error: {error.Tag}");
}
}
}
}
}
Loading

0 comments on commit 4e44a92

Please sign in to comment.