Files
FeedCenter/Application/MainWindow/CommandLine.cs
Chris Kaczor b5f570688d More modernization
- Split generic "common" libraries into specific libraries
- Use other packages in lieu of custom code
- General cleanup
2023-04-05 16:06:38 -04:00

38 lines
1.2 KiB
C#

using System;
namespace FeedCenter
{
public partial class MainWindow
{
private void HandleCommandLine(string commandLine)
{
// If the command line is blank then ignore it
if (commandLine.Length == 0)
return;
// Pad the command line with a trailing space just to be lazy in parsing
commandLine += " ";
// Look for the feed URL in the command line
var startPosition = commandLine.IndexOf("feed://", StringComparison.Ordinal);
// If nothing was found then exit
if (startPosition <= 0) return;
// Advance past the protocol
startPosition += 7;
// Starting at the URL position look for the next space
var endPosition = commandLine.IndexOf(" ", startPosition, StringComparison.Ordinal);
// Extract the feed URL
var feedUrl = commandLine.Substring(startPosition, endPosition - startPosition);
// Add the HTTP protocol by default
feedUrl = "http://" + feedUrl;
// Create a new feed using the URL
HandleNewFeed(feedUrl);
}
}
}