public Task <int> ExecuteCommandAsync( [Service] IWebShellFactory webShellFactory, ExecuteCommandInput input) { IWebShell shell = webShellFactory.CreateShell(input.Shell ?? "cmd"); return(shell.ExecuteAsync(new ShellCommand(input.Command) { Arguments = input.Arguments, WorkDirectory = input.WorkDirectory })); }
public async Task <int> ExecuteFileActionAsync(string fileName, string action) { FileInfo file = new(fileName); switch (action) { case "Execute": IWebShell shell = _webShellFactory.CreateShell(GetShellByFile(file)); return(await shell.ExecuteAsync(new ShellCommand($".{Path.DirectorySeparatorChar}{file.Name}") { WorkDirectory = file.Directory !.FullName }));
public async Task <CloneGitRepositoryPayload> CloneRepositoryAsync( [Service] IWebShellFactory webShellFactory, CloneGitRepositoryInput input) { IWebShell shell = webShellFactory.CreateShell(); var result = await shell.ExecuteAsync(new ShellCommand("git") { Arguments = $"clone {input.Url}", WorkDirectory = input.Directory }); var gitPath = input.Url.Split('/').Last().Replace(".git", ""); var dir = System.IO.Path.Combine(input.Directory, gitPath); return(new CloneGitRepositoryPayload(result, dir)); }