statiqdev / Statiq.Framework

A flexible and extensible static content generation framework for .NET.
https://statiq.dev/framework
MIT License
425 stars 74 forks source link

'--help' CLI option throws error in Statiq.Framework 1.0.0-beta.41 #186

Closed harrison314 closed 3 years ago

harrison314 commented 3 years ago

Running a Statiq.Framework 1.0.0-beta.41 app with options --help command always results in this error message:

Error: Could not find color or style 'analyzer'.

My bootstraper code:

return await Bootstrapper
                .Factory.Create(args)
                .AddDefaultShortcodes()
                .AddGlobCommands()
                .AddDefaults(DefaultFeatures.BuildCommands | DefaultFeatures.Logging| DefaultFeatures.Pipelines)
                .AddPipeline<Pipelines.AssertPipeline>()
                .AddPipeline<Pipelines.RazorPipeline>()
                .AddPipeline<Pipelines.BlogPipeline>()
                .AddSetting(Keys.LinkLowercase, false)
                .AddSetting(Keys.LinksUseHttps, true)
                .AddSetting(Keys.LinkHideExtensions, false)
                .AddSetting(BlogKeys.UseAbsoluteUrls, false)
                .AddSetting(Keys.Host, "harrison314.github.io")
                .AddSetting(Keys.Title, "harrison314 blog")
                .AddSetting(FeedKeys.Author, "harrison314")
                .AddSetting(FeedKeys.Description, "Blog jedného skeptického programátora.")
                .AddSetting(FeedKeys.Copyright, $"harrison314 © {DateTime.UtcNow.Year.ToString()}")
                .AddSetting(BlogKeys.MinifyOutput, false)
                .AddSetting(BlogKeys.GithubRepo, "https://github.com/harrison314/")
                .RunAsync();
patriksvensson commented 3 years ago

That's Spectre.Console. Try updating the version to the latest one if possible.

harrison314 commented 3 years ago

Using the Spectre.Console in versions 0.38.0 and 0.39.0 program throws next error:

Unhandled exception. System.TypeLoadException: Method 'RegisterLazy' in type 'Statiq.App.CommandServiceTypeRegistrar' from assembly 'Statiq.App, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
   at Statiq.App.Bootstrapper..ctor(String[] arguments)
   at Statiq.App.BootstrapperFactory.Create(String[] args)
   at Harrison314Blog.Program.Main(String[] args) 
patriksvensson commented 3 years ago

Seems like there are two versions of Statiq referencing different versions of Spectre.Console.

daveaglick commented 3 years ago

Seems like there are two versions of Statiq referencing different versions of Spectre.Console.

The only Spectre.Console reference is in Statiq.App - is gets brought into everything else transitively. I'll guess that the missing method exception happened because Statiq.App (and other Statiq Libraries) are bound to Spectre.Console 0.37.0 so when you updated Spectre.Console locally it broke that binding due to method differences (that's mostly to be expected).

The real question is why you're seeing an error with the help command in the first place. I can replicate, so best thing now is probably to update the Spectre.Console version in use by Statiq officially since updating locally creates a compatibility break. I'll do that for the next release (out in a day or two, just finishing up a few caching things).

image

patriksvensson commented 3 years ago

@daveaglick Any [ or ] in descriptions must be escaped since we allow markup there.

image

daveaglick commented 3 years ago

Ah, that makes sense @patriksvensson, I'm guessing I've got at least one set of brackets somewhere carried over from Spectre.Cli use. Should be easy enough to fix up.

patriksvensson commented 3 years ago

@daveaglick The CommandOption and CommandAttribute should not be escaped. Only things like descriptions.

patriksvensson commented 3 years ago

@daveaglick I can submit a PR for this if you want

daveaglick commented 3 years ago

Nah, I'll get it...unless you really want to :)

daveaglick commented 3 years ago

This is resolved, it'll ship with the next release soon.

daveaglick commented 3 years ago

Thanks for the bug report!