feat(git-provider): add inital implementation for New-GitRepo
This commit is contained in:
parent
1b09d15937
commit
830ae2c560
1 changed files with 32 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Management.Automation;
|
||||
using System.Management.Automation.Provider;
|
||||
|
||||
|
|
@ -66,3 +67,34 @@ public class GitProvider : NavigationCmdletProvider
|
|||
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();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue