2024-06-19 21:11:42 -04:00
using CliFx ;
using CliFx.Attributes ;
using CliFx.Infrastructure ;
using ReCodeIt.CrossCompiler ;
2024-06-19 21:34:46 -04:00
using ReCodeIt.Utils ;
2024-06-19 21:11:42 -04:00
using ReCodeItLib.Utils ;
namespace ReCodeIt.Commands ;
[Command("Build", Description = "Build your project and get a dll output for the original assembly. You dont need to provide a path if the last project you built is the one you want to target")]
public class BuildCommand : ICommand
{
private ReCodeItCrossCompiler CrossCompiler { get ; set ; }
[CommandParameter(0, IsRequired = false, Description = "the location of your project file")]
public string ProjectJsonPath { get ; init ; }
public ValueTask ExecuteAsync ( IConsole console )
{
if ( ProjectJsonPath is not null & & ProjectJsonPath ! = string . Empty )
{
CrossCompiler = new ( ) ;
ProjectManager . LoadProject ( ProjectJsonPath ) ;
CrossCompiler . StartCrossCompile ( ) ;
return default ;
}
console . Output . WriteLine ( RegistryHelper . GetRegistryValue < string > ( "LastLoadedProject" ) ) ;
if ( RegistryHelper . GetRegistryValue < string > ( "LastLoadedProject" ) ! = null )
{
CrossCompiler = new ( ) ;
2024-06-19 21:34:46 -04:00
DataProvider . LoadAppSettings ( ) ;
2024-06-19 21:11:42 -04:00
ProjectManager . LoadProject ( RegistryHelper . GetRegistryValue < string > ( "LastLoadedProject" ) , true ) ;
CrossCompiler . StartCrossCompile ( ) ;
2024-06-19 21:34:46 -04:00
DataProvider . SaveAppSettings ( ) ;
2024-06-19 21:11:42 -04:00
return default ;
}
return default ;
}
}