feat(git-provider): add inital implementation for New-GitRepo

This commit is contained in:
Scott 2026-08-07 08:51:54 +10:00
commit 830ae2c560

View file

@ -1,4 +1,5 @@
using System; using System;
using System.Diagnostics;
using System.Management.Automation; using System.Management.Automation;
using System.Management.Automation.Provider; using System.Management.Automation.Provider;
@ -65,4 +66,35 @@ public class GitProvider : NavigationCmdletProvider
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
}
[Cmdlet(VerbsCommon.New, Noun)]
public class RegisterGitRepo : PSCmdlet
{
private const string Noun = "GitRepo";
[Parameter(
Mandatory = true,
Position = 0,
ValueFromPipeline = true,
HelpMessage = "Reference name for the repo")]
public string Name { get; set; }
protected override void BeginProcessing()
{
var pwd = this.SessionState.Path.CurrentLocation.Path;
WriteObject("Checking if current directory is a git repository...");
var ps = new ProcessStartInfo( //$"git -C \"{pwd}\" rev-parse --show-toplevel")
"git", ["rev-parse", "--show-toplevel"])
{
RedirectStandardOutput = true,
RedirectStandardError = true,
WorkingDirectory = pwd
};
var a = Process.Start(ps);
Console.WriteLine(a.StandardOutput.ReadToEnd());
Console.WriteLine(a.StandardError.ReadToEnd());
base.BeginProcessing();
}
} }