public WebDAVCommand(ILogger <TailCommand> logger, IConsoleOutput console, IWebDAVClient client, IOptions <SFCCEnvironment> _envOption) { _env = _envOption.Value; _logger = logger; _console = console; _client = client; _location = WebDAVLocation.Logs; // use a dummy URI for managing location state _workingDirectory = new Uri("/", UriKind.Absolute); _localWorkingDirectory = Directory.GetCurrentDirectory(); }
public async Task <int> RunCommand(WebDAVLocation location, string directory = "") { if (!string.IsNullOrEmpty(location.Value)) { _location = location; } if (!string.IsNullOrEmpty(directory)) { directory = directory.EndsWith("/") ? directory : directory + "/"; _workingDirectory = new Uri("/" + directory, UriKind.Absolute); } _app = new CommandLineApplication { Name = "" }; _app.HelpOption(inherited: true); _app.Command("ls", LsCommandHandler); _app.Command("lcd", LcdCommandHandler); _app.Command("cd", CdCommandHandler); _app.Command("get", GetCommandHandler); while (true) { DisplayPrompt(); var cmd = _console.ReadLine(); if (cmd == null) { return(0); } try { var result = await _app.ExecuteAsync(cmd.Split(" ")); } catch (CommandParsingException ex) { _console.Red("Invalid command."); continue; } } return(0); }