Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default CoconaApp isn't very suitable for Linux CLI tools #132

Open
GGG-KILLER opened this issue Mar 8, 2024 · 0 comments
Open

Default CoconaApp isn't very suitable for Linux CLI tools #132

GGG-KILLER opened this issue Mar 8, 2024 · 0 comments

Comments

@GGG-KILLER
Copy link

GGG-KILLER commented Mar 8, 2024

The default CoconaApp makes it so that your app creates a FileSystemWatcher for the current directory the app is running on, which means it recursively lists all files in the current directory.

This made my app take over 5 minutes to run the --help command when I ran it from /.

My solution to this ended up being creating my own HostBuilder and then manually setting everything up:

var builder = new HostBuilder();
builder.ConfigureServices((context, services) =>
{
    services.AddLogging(logging =>
    {
        logging.AddSimpleConsole(x =>
        {
            x.ColorBehavior = Microsoft.Extensions.Logging.Console.LoggerColorBehavior.Enabled;
            x.IncludeScopes = true;
            x.SingleLine = true;
            x.TimestampFormat = "HH:mm:ss ";
        });
        logging.AddDebug();

        logging.Configure(options =>
        {
            options.ActivityTrackingOptions =
                ActivityTrackingOptions.SpanId |
                ActivityTrackingOptions.TraceId |
                ActivityTrackingOptions.ParentId;
        });
    });

    // Configure other services.
});

builder.ConfigureCocona(args, configureApplication: app =>
{
    // Configure your app's commands normally as you would with app
});

await builder.RunConsoleAsync(x => x.SuppressStatusMessages = true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant