1
0
Fork 0
mirror of https://github.com/sbrl/PolyFeed.git synced 2024-12-25 10:55:01 +00:00

Fill out CLI, but it's all untested.

This commit is contained in:
Starbeamrainbowlabs 2019-07-28 21:19:29 +01:00
parent b497ffb0d7
commit 521ce61bc1
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 21 additions and 2 deletions

View file

@ -87,7 +87,16 @@ namespace PolyFeed
: lastUpdatedNode.Attributes[source.EntryLastUpdatedAttribute].DeEntitizeValue
);
}
await feed.Write(nextItem);
}
}
public string Render()
{
xml.Flush();
xml.WriteEndDocument();
return result.ToString();
}
}
}

View file

@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Nett;
namespace PolyFeed
@ -79,19 +81,27 @@ namespace PolyFeed
return 0;
}
private static void run()
private static async Task<string> run()
{
FeedSource feedSource = new FeedSource();
TomlTable config = Toml.ReadFile(settings.ConfigFilepath, TomlSettings.Create());
foreach (KeyValuePair<string, TomlObject> item in config) {
string key = item.Key;
string key = Regex.Replace(
item.Key,
@"(^|_)[A-Za-z0-9]",
(match) => match.Value.Replace("_", "").ToUpper()
);
string value = item.Value.Get<TomlString>().Value;
feedSource.GetType().GetProperty(value).SetValue(
feedSource,
value
);
}
FeedBuilder feedBuilder = new FeedBuilder();
await feedBuilder.AddSource(feedSource);
return await feedBuilder.Render();
}