sourcegit/src/Commands/Clone.cs

34 lines
890 B
C#
Raw Normal View History

using System;
2021-04-29 05:05:55 -07:00
namespace SourceGit.Commands
{
public class Clone : Command
{
private readonly Action<string> _notifyProgress;
2021-04-29 05:05:55 -07:00
public Clone(string ctx, string path, string url, string localName, string sshKey, string extraArgs, Action<string> ouputHandler)
{
Context = ctx;
WorkingDirectory = path;
2021-04-29 05:05:55 -07:00
TraitErrorAsOutput = true;
2024-07-09 03:13:15 -07:00
SSHKey = sshKey;
Args = "clone --progress --verbose --recurse-submodules ";
if (!string.IsNullOrEmpty(extraArgs))
Args += $"{extraArgs} ";
2024-07-09 03:13:15 -07:00
2021-04-29 05:05:55 -07:00
Args += $"{url} ";
2024-07-09 03:13:15 -07:00
if (!string.IsNullOrEmpty(localName))
Args += localName;
2021-04-29 05:05:55 -07:00
_notifyProgress = ouputHandler;
2021-04-29 05:05:55 -07:00
}
protected override void OnReadline(string line)
{
_notifyProgress?.Invoke(line);
}
2021-04-29 05:05:55 -07:00
}
}