Skip to content

Commit

Permalink
Add URL open and change icons [release]
Browse files Browse the repository at this point in the history
  • Loading branch information
timheuer committed Feb 19, 2022
1 parent 2f7511e commit 04a98ef
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ jobs:
with:
extension-file: '${{ github.event.repository.name }}.vsix'
publish-manifest-file: 'vs-publish.json'
personal-access-code: ${{ secrets.VS_PUBLISHER_ACCESS_TOKEN }}
personal-access-code: ${{ secrets.VS_PUBLISHER_ACCESS_TOKEN }}
generate_release_notes: true
3 changes: 2 additions & 1 deletion AddActionsWorkflow/AddActionsWorkflow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Commands\LaunchRemoteUrlCommand.cs" />
<Compile Include="Options\General.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Commands\MyCommand.cs" />
<Compile Include="Commands\AddWorkflowCommand.cs" />
<Compile Include="AddActionsWorkflowPackage.cs" />
<Compile Include="source.extension.cs">
<AutoGen>True</AutoGen>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

namespace AddActionsWorkflow;

[Command(PackageIds.MyCommand)]
internal sealed class MyCommand : BaseCommand<MyCommand>
[Command(PackageIds.AddWorkflowCommand)]
internal sealed class AddWorkflowCommand : BaseCommand<AddWorkflowCommand>
{
string finaleWorkflowname = "";
string branchName = "main";
Expand Down
47 changes: 47 additions & 0 deletions AddActionsWorkflow/Commands/LaunchRemoteUrlCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using AddActionsWorkflow.Options;
using CliWrap;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AddActionsWorkflow.Commands
{
[Command(PackageIds.LaunchRemoteUrlCommand)]
internal class LaunchRemoteUrlCommand : BaseCommand<LaunchRemoteUrlCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
// get the repo URI
var dirInfo = new DirectoryInfo((await VS.Solutions.GetCurrentSolutionAsync()).FullPath);
var slnDir = dirInfo.Parent.FullName;

var stdOutBuffer = new StringBuilder();
var stdErrBuffer = new StringBuilder();

var result = await Cli.Wrap("git")
.WithArguments("remote get-url origin --push")
.WithWorkingDirectory(slnDir)
.WithStandardOutputPipe(PipeTarget.ToStringBuilder(stdOutBuffer))
.WithStandardErrorPipe(PipeTarget.ToStringBuilder(stdErrBuffer))
.WithValidation(CommandResultValidation.None)
.ExecuteAsync();

var stdOut = stdOutBuffer.ToString();
var stdErr = stdErrBuffer.ToString();

if (result.ExitCode == 0)
{
_ = Process.Start(stdOut);
}
else
{
var argError = new UriFormatException(stdErr);
await argError.LogAsync();
}
}
}
}
Binary file modified AddActionsWorkflow/Resources/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions AddActionsWorkflow/VSCommandTable.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This file was generated by VSIX Synchronizer
// Available from https://marketplace.visualstudio.com/items?itemName=MadsKristensen.VsixSynchronizer64
// </auto-generated>
// ------------------------------------------------------------------------------
namespace AddActionsWorkflow
{
using System;

/// <summary>
/// Helper class that exposes all GUIDs used across VS Package.
/// </summary>
Expand All @@ -16,13 +15,13 @@ internal sealed partial class PackageGuids
public const string AddActionsWorkflowString = "ff8107ff-c891-4674-878d-c283252ce550";
public static Guid AddActionsWorkflow = new Guid(AddActionsWorkflowString);
}

/// <summary>
/// Helper class that encapsulates all CommandIDs uses across VS Package.
/// </summary>
internal sealed partial class PackageIds
{
public const int MyMenuGroup = 0x0001;
public const int MyCommand = 0x0100;
public const int AddWorkflowCommand = 0x0100;
public const int LaunchRemoteUrlCommand = 0x0101;
}
}
}
17 changes: 9 additions & 8 deletions AddActionsWorkflow/VSCommandTable.vsct
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
<!--This section defines the elements the user can interact with, like a menu command or a button
or combo box in a toolbar. -->
<Buttons>
<Button guid="AddActionsWorkflow" id="MyCommand" priority="0x0100" type="Button">
<Button guid="AddActionsWorkflow" id="AddWorkflowCommand" priority="0x0100" type="Button">
<Parent guid="AddActionsWorkflow" id="MyMenuGroup" />
<Icon guid="ImageCatalogGuid" id="CodeInformation" />
<Icon guid="ImageCatalogGuid" id="CSWorkflow" />
<CommandFlag>IconIsMoniker</CommandFlag>
<Strings>
<ButtonText>Add GitHub Actions Workflow</ButtonText>
<LocCanonicalName>.AddActionsWorkflow.AddWorkflow</LocCanonicalName>
</Strings>
</Button>
<Button guid="AddActionsWorkflow" id="MyCommand" priority="0x0100" type="Button">
<Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_PROJECT_ADD_ITEMS" />
<Icon guid="ImageCatalogGuid" id="CodeInformation" />
<Button guid="AddActionsWorkflow" id="LaunchRemoteUrlCommand" priority="0x0101" type="Button">
<Parent guid="AddActionsWorkflow" id="MyMenuGroup" />
<Icon guid="ImageCatalogGuid" id="OpenWebSite" />
<CommandFlag>IconIsMoniker</CommandFlag>
<Strings>
<ButtonText>GitHub Actions Workflow</ButtonText>
<LocCanonicalName>.AddActionsWorkflow.AddWorkflow</LocCanonicalName>
<ButtonText>Open GitHub Repo</ButtonText>
<LocCanonicalName>.AddActionsWorkflow.LaunchRepoUrl</LocCanonicalName>
</Strings>
</Button>
</Buttons>
Expand All @@ -55,7 +55,8 @@
<Symbols>
<GuidSymbol name="AddActionsWorkflow" value="{ff8107ff-c891-4674-878d-c283252ce550}">
<IDSymbol name="MyMenuGroup" value="0x0001" />
<IDSymbol name="MyCommand" value="0x0100" />
<IDSymbol name="AddWorkflowCommand" value="0x0100" />
<IDSymbol name="LaunchRemoteUrlCommand" value="0x0101" />
</GuidSymbol>
</Symbols>
</CommandTable>

0 comments on commit 04a98ef

Please sign in to comment.