in src/BuildScriptGeneratorCli/Commands/BuildCommand.cs [297:363]
internal override bool IsValidInput(IServiceProvider serviceProvider, IConsole console)
{
var options = serviceProvider.GetRequiredService<IOptions<BuildScriptGeneratorOptions>>().Value;
var logger = serviceProvider.GetRequiredService<ILogger<BuildCommand>>();
if (_languageWasSet)
{
logger.LogWarning("Deprecated option '--language' used");
console.WriteLine("Warning: the deprecated option '--language' was used.");
}
if (_languageVersionWasSet)
{
logger.LogWarning("Deprecated option '--language-version' used");
console.WriteLine("Warning: the deprecated option '--language-version' was used.");
}
// Invalid to specify platform version without platform name
if (string.IsNullOrEmpty(options.PlatformName) && !string.IsNullOrEmpty(options.PlatformVersion))
{
logger.LogError("Cannot use lang version without lang name");
console.WriteErrorLine("Cannot use platform version without specifying platform name also.");
return false;
}
if (!string.IsNullOrEmpty(options.AppType))
{
var appType = options.AppType.ToLower();
if (!string.Equals(appType, Constants.FunctionApplications)
&& !string.Equals(appType, Constants.StaticSiteApplications)
&& !string.Equals(appType, Constants.WebApplications))
{
logger.LogError($"Invalid value for AppType: '{options.AppType}'.");
console.WriteErrorLine(
$"Invalid value '{options.AppType}' for switch '--apptype'. " +
$"Valid values are '{Constants.StaticSiteApplications}' or " +
$"'{Constants.FunctionApplications}' or '{Constants.WebApplications}'");
return false;
}
}
if (!string.IsNullOrEmpty(options.IntermediateDir))
{
if (DirectoryHelper.AreSameDirectories(options.IntermediateDir, options.SourceDir))
{
logger.LogError(
"Intermediate directory cannot be same as the source directory.");
console.WriteErrorLine(
$"Intermediate directory '{options.IntermediateDir}' cannot be " +
$"same as the source directory '{options.SourceDir}'.");
return false;
}
// Intermediate directory cannot be a sub-directory of the source directory
if (DirectoryHelper.IsSubDirectory(options.IntermediateDir, options.SourceDir))
{
logger.LogError(
"Intermediate directory cannot be a child of the source directory.");
console.WriteErrorLine(
$"Intermediate directory '{options.IntermediateDir}' cannot be a " +
$"sub-directory of source directory '{options.SourceDir}'.");
return false;
}
}
return true;
}