public IptcBuildStep(ImageCasterConfig config, StringInterpolator interpolator) { this.Config = config.Build.Metadata.RequireNonNull(); Interpolator = interpolator.RequireNonNull(); Dictionary <string, string> variables = config.Variables; if (config.Variables != null) { foreach ((string key, string value) in variables) { Interpolator.Add(key, value); } } }
/// <summary>Load the configuration from the provided <see cref="TextReader"/>.</summary> /// <param name="reader">The text reader to read the string from for the configuration.</param> /// <returns>A data object that represents the configuration passed.</returns> public static ImageCasterConfig Load(TextReader reader) { reader.RequireNonNull(); IDeserializer deserializer = new DeserializerBuilder().Build(); object yamlObject = deserializer.Deserialize(reader); ISerializer serializer = new SerializerBuilder().JsonCompatible().Build(); string json = serializer.Serialize(yamlObject); JsonSerializerOptions options = new JsonSerializerOptions(); options.AddImageCasterConverters(); ImageCasterConfig config = JsonSerializer.Deserialize <ImageCasterConfig>(json, options); return(config); }
public IptcBuildStep(ImageCasterConfig config) : this(config, new StringInterpolator()) { }
public ResizeBuildStep(ImageCasterConfig config) { this.Config = config.Build.Resize.RequireNonNull(); }
/// <param name="config"><see cref="Config"/></param> public MontageAction(ImageCasterConfig config) { this.Config = config.RequireNonNull(); }
/// <summary> /// Intialize ImageCaster commands, parse arguments, /// and process the command the user input. /// /// This method also times the time taken to perform /// the command to help optimizations in development /// or user configurations. /// </summary> /// <param name="args">Command line arguments.</param> /// <returns>The exit code.</returns> public static async Task <int> Main(string[] args) { RootCommand command = new RootCommand("Perform aggregate tasks against a collection of images") { new Command("archive", "Archive collections of images or files into compressed archives") { Handler = CommandHandler.Create <FileInfo>((file) => { try { ImageCasterConfig config = ConfigurationFile.LoadFromFile(file.FullName); IAction action = new ArchiveAction(config); try { action.Execute(); } catch (ConfigurationException ex) { Logger.Error(ex.Message); return((int)ExitCode.MalformedConfigFields); } catch (FileNotFoundException ex) { Logger.Error(ex.Message); return((int)ExitCode.MalformedConfigFields); } catch (Exception ex) { return(OnInternalException(ex)); } } catch (JsonException ex) { return(OnJsonException(ex)); } return((int)ExitCode.Normal); }) }, new Command("build", "Export the output images from the source") { Handler = CommandHandler.Create <FileInfo>((file) => { try { ImageCasterConfig config = ConfigurationFile.LoadFromFile(file.FullName); IAction action = new BuildAction(config); try { action.Execute(); } catch (ConfigurationException ex) { Logger.Error(ex.Message); return((int)ExitCode.MalformedConfigFields); } catch (Exception ex) { return(OnInternalException(ex)); } return((int)ExitCode.Normal); } catch (JsonException ex) { return(OnJsonException(ex)); } }) }, new Command("check", "Validate that the project structure and standards are maintained") { Handler = CommandHandler.Create <FileInfo>((file) => { try { ImageCasterConfig config = ConfigurationFile.LoadFromFile(file.FullName); IAction action = new CheckAction(config.Checks); try { action.Execute(); } catch (ConfigurationException ex) { Logger.Error(ex.Message); return((int)ExitCode.MalformedConfigFields); } catch (ValidationException ex) { Logger.Error(ex.Message); return((int)ExitCode.CheckFailures); } catch (Exception ex) { return(OnInternalException(ex)); } } catch (JsonException ex) { return(OnJsonException(ex)); } return((int)ExitCode.Normal); }) }, new Command("montage", "Export a single image comprised of all matching output images") { Handler = CommandHandler.Create <FileInfo>((file) => { try { ImageCasterConfig config = ConfigurationFile.LoadFromFile(file.FullName); IAction action = new MontageAction(config); try { action.Execute(); } catch (ConfigurationException ex) { Logger.Error(ex.Message); return((int)ExitCode.MalformedConfigFields); } catch (Exception ex) { return(OnInternalException(ex)); } } catch (JsonException ex) { return(OnJsonException(ex)); } return((int)ExitCode.Normal); }) } }; command.Name = "imagecaster"; CommandLineBuilder commandLineBuilder = new CommandLineBuilder(command) { EnableDirectives = false }; // Default middlewares we want to add to our console application. commandLineBuilder.UseVersionOption().UseHelp().UseParseErrorReporting().CancelOnProcessTermination(); // These are our own defined middlewares. commandLineBuilder.UseLogger().UseTimer().UseLicense().UseImageCaster(); Parser parser = commandLineBuilder.Build(); return(await parser.InvokeAsync(args)); }
public void Check([FromBody] ImageCasterConfig config) { CheckAction check = new CheckAction(config.Checks); check.Execute(); }
public void Archive([FromBody] ImageCasterConfig config) { ArchiveAction archive = new ArchiveAction(config); archive.Execute(); }
public void Montage([FromBody] ImageCasterConfig config) { MontageAction montage = new MontageAction(config); montage.Execute(); }
public void Build([FromBody] ImageCasterConfig config) { BuildAction build = new BuildAction(config); build.Execute(); }