wip
This commit is contained in:
commit
f1d7d6accc
33 changed files with 1676 additions and 0 deletions
57
src/core/Commands/Release.cs
Normal file
57
src/core/Commands/Release.cs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
using System.CommandLine;
|
||||
using Geekeey.Core.Properties;
|
||||
using Microsoft.Extensions.FileSystemGlobbing;
|
||||
|
||||
namespace Geekeey.Core.Commands;
|
||||
|
||||
internal sealed class Release : Command
|
||||
{
|
||||
private static readonly Option<Uri> Repository = new("--repository") { Required = true, CustomParser = Parsers.Uri };
|
||||
private static readonly Option<string> Version = new("--version") { Required = true };
|
||||
|
||||
private static readonly Option<Pattern> Draft = new("--draft") { CustomParser = Parsers.Pattern };
|
||||
private static readonly Option<Pattern> PreRelease = new("--prerelease") { CustomParser = Parsers.Pattern };
|
||||
|
||||
private static readonly Option<string> Title = new("--title");
|
||||
private static readonly Option<string> Notes = new("--notes");
|
||||
private static readonly Option<Matcher> Attachments = new("--attachments") { CustomParser = Parsers.Matcher };
|
||||
|
||||
public Release() : base("release", Resources.ReleaseCommandDescription)
|
||||
{
|
||||
Add(Repository);
|
||||
Add(Version);
|
||||
|
||||
Add(Draft);
|
||||
Add(PreRelease);
|
||||
|
||||
Add(Title);
|
||||
Add(Notes);
|
||||
Add(Attachments);
|
||||
|
||||
SetAction(HandleAsync);
|
||||
}
|
||||
|
||||
private Task<int> HandleAsync(ParseResult result, CancellationToken cancellationToken)
|
||||
{
|
||||
var server = result.GetRequiredValue(Program.Server);
|
||||
var access = result.GetRequiredValue(Program.Token);
|
||||
|
||||
// relative repository urls are resolved against the server url
|
||||
var repository = result.GetRequiredValue(Repository);
|
||||
if (!repository.IsAbsoluteUri)
|
||||
{
|
||||
repository = new Uri(new Uri(server), repository);
|
||||
}
|
||||
|
||||
var version = result.GetRequiredValue(Version);
|
||||
var draft = result.GetValue(Draft);
|
||||
var prerelease = result.GetValue(PreRelease);
|
||||
|
||||
var title = result.GetValue(Title);
|
||||
var notes = result.GetValue(Notes);
|
||||
var attachments = result.GetValue(Attachments);
|
||||
|
||||
// Implementation for checkout command goes here.
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue