public void Squash(SquashConfiguration configuration) { var squashFeatureDirectory = new SquashFeatureDirectory(configuration.InputDirectory); var template = new PageTemplate(squashFeatureDirectory, configuration.OutputDirectory, configuration.Title); var htmlGenerator = new HtmlGenerator(template, configuration.OutputDirectory, squashFeatureDirectory); htmlGenerator.ClearOutputDirectory(); htmlGenerator.GenerateFiles(); SquashLogger.Info("Done!"); }
public void GenerateBlankConfigFile(string configFileLocation) { SquashConfiguration blankConfig = new SquashConfiguration(); blankConfig.InputDirectory = "[[Enter input directory]]"; blankConfig.OutputDirectory = "[[Enter output directory]]"; blankConfig.Title = "[[Title]]"; var config = JsonConvert.SerializeObject(blankConfig, Formatting.Indented); File.WriteAllText(configFileLocation, config); }
static void Main(string[] args) { Squasher squasher = new Squasher(new Logger()); var inputDirectory = "/Users/maisiesadler/Downloads/input/"; var outputDirectory = "/Users/maisiesadler/Downloads/output"; var squashConfiguration = new SquashConfiguration(title: "Title", inputDirectory: inputDirectory, outputDirectory: outputDirectory); if (squashConfiguration.Validate()) { squasher.Squash(squashConfiguration); } }
public SquashConfiguration(string configLocation) { if (!File.Exists(configLocation)) { SquashLogger.Error("Configuration file does not exist"); return; } var file = File.ReadAllText(configLocation); if (string.IsNullOrWhiteSpace(file)) { SquashLogger.Error("File is empty"); return; } SquashConfiguration config = null; try { config = JsonConvert.DeserializeObject <SquashConfiguration>(file); } catch (Exception ex) { SquashLogger.Error("Error parsing config file: " + ex.Message); } if (config == null) { SquashLogger.Error("Config file is not in the correct format"); return; } Title = config.Title; InputDirectory = config.InputDirectory; OutputDirectory = config.OutputDirectory; Validate(); }