public override void RunFromArgs(string[] args) { string mapName = null; string outName = null; string layerName = null; OptionSet optionSet = new OptionSet() { {"m|map=", x => mapName = x}, {"o|out=", x => outName = x}, {"l|layer=", x => layerName = x} }; List<string> entityNames = optionSet.Parse(args); if (mapName == null) { throw new ApplicationException(); } if (outName == null) { outName = mapName; } if (layerName == null) { throw new ApplicationException(); } mapName = FormatFolderPath(mapName); outName = FormatFolderPath(outName, Path.GetFileNameWithoutExtension(mapName)); IMap map; try { map = new Map(ReadAllBytes(mapName)); } catch (FileNotFoundException e) { throw new ApplicationException(); } IEnumerable<IEntityInstance> entities = map.GetEntitiesWithName(entityNames.Distinct()); ILayer layer = map.GetOrCreateLayer(layerName); foreach (IEntityInstance entity in entities) { entity.AddToLayer(layer); } WriteAllBytes(outName, map.Write()); }