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

#35727 Add standard data directory output to relevant commands. #560

Open
wants to merge 2 commits into
base: develop/2024.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Metalama.Tool/InfoCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.

using Metalama.Backstage.Commands;
using Metalama.Backstage.Extensibility;
using Metalama.Backstage.Infrastructure;
using Metalama.Framework.Engine.Utilities;

namespace Metalama.Tool;

internal class InfoCommand : BaseCommand<BaseCommandSettings>
{
protected override void Execute( ExtendedCommandContext context, BaseCommandSettings settings )
{
context.Console.WriteSuccess( $"Metalama Tool v{EngineAssemblyMetadataReader.Instance.PackageVersion ?? "<unknown>"}" );

var standardDirectories = context.ServiceProvider.GetBackstageService<IStandardDirectories>();

if ( standardDirectories != null )
{
context.Console.WriteImportantMessage( $"Application data directory: {standardDirectories.ApplicationDataDirectory}" );
context.Console.WriteImportantMessage( $"Temp directory: {standardDirectories.TempDirectory}" );
}
}

protected override BackstageInitializationOptions AddBackstageOptions( BackstageInitializationOptions options ) => options with { AddUserInterface = true };
}
4 changes: 4 additions & 0 deletions Metalama.Tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ void ConfigureMoreCommands( IConfigurator config )
.WithData( options )
.WithDescription( "Copies code generated by Metalama back into your source code, in case you wanted to stop using Metalama." );

config.AddCommand<InfoCommand>( "info" )
.WithData( options )
.WithDescription( "Displays diagnostic information about the 'metalama' global tool." );

config.AddCommand<VersionCommand>( "version" )
.WithData( options )
.WithDescription( "Displays the version of the 'metalama' global tool." );
Expand Down