Git Product home page Git Product logo

Comments (4)

markopolo89 avatar markopolo89 commented on August 25, 2024 1

Thanks for the suggestion. I'll investigate this further. As an interim measure I have replicated the FakeInMemoryConsole and added a clear method to clear the memory streams. This gets me moving for my current task.

from clifx.

Tyrrrz avatar Tyrrrz commented on August 25, 2024

Hi.

Indeed, the Clear() method doesn't do anything in FakeConsole. It may make sense to make it virtual and override in FakeInMemoryConsole to clear the in-memory streams.

That said, I'm not sure if it's the best solution for your problem. Can you give some example of what you're trying to achieve? I think, in your situation, I would not write to the console at all, but instead use some sort of logging abstraction and configure it to send data to your websocket interface.

from clifx.

markopolo89 avatar markopolo89 commented on August 25, 2024

Thanks for your quick response. Yes, I agree that this is not the best solution.

If, for example, a command argument is incorrect and I would like to raise a command exception, I would like to be able to intercept this at a high level and send the error message to the client across the web-socket interface.

Even in a scenario, where the execute function is not being called because a parameter is missing, again I would like to intercept the "Missing parameter" message and transmit back to the client. I think this would be useful.

In general, what I am trying to achieve is to have the benefits of the CliFx parsing and error reporting functionality but to have access to the meaningful messages that get output to the console window and in the event of an error transmit them across to the client using the websocket interface.

from clifx.

Tyrrrz avatar Tyrrrz commented on August 25, 2024

I see what you mean. This is kind of an unusual use case, I would say. Maybe for your case it would make sense to create a custom IConsole that uses a custom Stream that sends data off to the websocket interface you have? And then some sort of AggregateConsole that combines it together with the existing IConsole instance you get from CliFx. You would need to provide your own ConsoleWriter, but it should be fairly simple by replicating this internal method:

internal static ConsoleWriter Create(IConsole console, Stream stream) => new(
console,
Stream.Synchronized(stream)
) {AutoFlush = true};

from clifx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.