public CommandResponse GetResponse(ICommandContext commandContext) { var fileSystem = commandContext.CreateFileSystem(); // If no target directory is specified (as on first init), use a working directory, if // specified. var hash = string.IsNullOrEmpty(commandContext.Parameters["target"]) ? commandContext.Parameters["working"] : commandContext.Parameters["target"]; var response = new OpenCommandResponse { tmb = false, disabled = commandContext.DisabledCommands.ToArray(), parameters = new InitializationParameters { dotFiles = false, archives = new string[] {}, extract = new string[] {}, } }; DirectoryContentHash cwd; if (DirectoryContentHash.TryParse(hash, out cwd)) { try { return(fileSystem.Using(cwd, fs => GetResponse(commandContext, fs, response))); } catch (InvalidOperationException e) { response.error = e.Message; } } try { return(fileSystem.Using(fs => GetResponse(commandContext, fs, response))); } catch (InvalidOperationException e) { response.error = e.Message; return(response); } }
private static CommandResponse GetResponse(ICommandContext commandContext, IFileSystemContext fileSystemContext, OpenCommandResponse response, bool forceTree = false) { response.cwd = fileSystemContext.Current.Info; response.cdc = fileSystemContext.Current.Children; bool treeRequested; if (forceTree || (bool.TryParse(commandContext.Parameters["tree"] ?? string.Empty, out treeRequested) && treeRequested)) { response.tree = fileSystemContext.Tree; } return(response); }