Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions Source/NETworkManager.Localization/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Source/NETworkManager.Localization/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4857,4 +4857,34 @@ Cloudflare may log your IP address and network information. See Cloudflare's pri
<data name="Resource_PublicSuffixList_Description" xml:space="preserve">
<value>List of public suffixes (e.g. "co.uk") from publicsuffix.org (MPL-2.0), which is used to get the registered domain of a hostname for RDAP queries.</value>
</data>
<data name="ProfileXNotFound" xml:space="preserve">
<value>Profile "{0}" not found!</value>
</data>
<data name="SeveralProfilesAreNamedXSelectOne" xml:space="preserve">
<value>Several profiles are named "{0}", select one!</value>
</data>
<data name="EnterACommand" xml:space="preserve">
<value>Enter a command!</value>
</data>
<data name="UnknownCommandX" xml:space="preserve">
<value>Unknown command "{0}"!</value>
</data>
<data name="CommandXDoesNotAcceptArguments" xml:space="preserve">
<value>The command "{0}" does not accept arguments!</value>
</data>
<data name="CommandXDoesNotSupportProfiles" xml:space="preserve">
<value>The command "{0}" does not support profiles!</value>
</data>
<data name="EnterTheNameOfAProfileAfterAt" xml:space="preserve">
<value>Enter the name of a profile after "@"!</value>
</data>
<data name="UnknownArgumentX" xml:space="preserve">
<value>Unknown argument "{0}"!</value>
</data>
<data name="RunCommand" xml:space="preserve">
<value>Run command</value>
</data>
<data name="Recent" xml:space="preserve">
<value>Recent</value>
</data>
</root>
22 changes: 0 additions & 22 deletions Source/NETworkManager.Models/EventSystem/EventSystem.cs

This file was deleted.

This file was deleted.

12 changes: 12 additions & 0 deletions Source/NETworkManager.Models/RunCommand/RunCommandArgument.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace NETworkManager.Models.RunCommand;

/// <summary>
/// Second argument of a run command after the target.
/// </summary>
public enum RunCommandArgument
{
None,
Ports,
DNSServer,
Broadcast
}
68 changes: 68 additions & 0 deletions Source/NETworkManager.Models/RunCommand/RunCommandDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace NETworkManager.Models.RunCommand;

/// <summary>
/// Command of the run command dialog (e.g. "dnslookup" with the alias "dns"), which opens an application or the
/// settings.
/// </summary>
public sealed class RunCommandDefinition
{
/// <summary>
/// Whether the command opens an application or the settings.
/// </summary>
public RunCommandType Type { get; init; }

/// <summary>
/// Application to open (<see cref="ApplicationName.None" /> for the settings).
/// </summary>
public ApplicationName Application { get; init; }

/// <summary>
/// Command (lowercase, e.g. "dnslookup").
/// </summary>
public string Command { get; init; }

/// <summary>
/// Short forms of the command (lowercase, e.g. "dns", "nslookup").
/// </summary>
public IReadOnlyList<string> Aliases { get; init; } = [];

/// <summary>
/// The command accepts a target (e.g. host, IP range, query).
/// </summary>
public bool SupportsTarget { get; init; }

/// <summary>
/// The command accepts a profile ("@name") instead of a target.
/// </summary>
public bool SupportsProfile { get; init; }

/// <summary>
/// Second argument after the target (e.g. ports or DNS server).
/// </summary>
public RunCommandArgument Argument { get; init; }

/// <summary>
/// Type keywords that can follow the target (lowercase, e.g. "a", "aaaa" for the DNS lookup).
/// </summary>
public IReadOnlyList<string> Types { get; init; } = [];

/// <summary>
/// Syntax of the arguments for the hint (e.g. "&lt;hosts&gt; [server] [type]"), empty if there are none.
/// </summary>
public string Syntax { get; init; } = string.Empty;

/// <summary>
/// Checks if the text is the command or one of its aliases (case-insensitive).
/// </summary>
/// <param name="text">Command text.</param>
/// <returns>True if the text matches.</returns>
public bool Matches(string text)
{
return string.Equals(Command, text, StringComparison.OrdinalIgnoreCase) ||
Aliases.Any(x => string.Equals(x, text, StringComparison.OrdinalIgnoreCase));
}
}
15 changes: 15 additions & 0 deletions Source/NETworkManager.Models/RunCommand/RunCommandParseError.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace NETworkManager.Models.RunCommand;

/// <summary>
/// Errors of a run command input.
/// </summary>
public enum RunCommandParseError
{
None,
Empty,
UnknownCommand,
NoArguments,
NoProfiles,
MissingProfileName,
UnknownArgument
}
63 changes: 63 additions & 0 deletions Source/NETworkManager.Models/RunCommand/RunCommandParseResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
namespace NETworkManager.Models.RunCommand;

/// <summary>
/// Result of <see cref="RunCommandParser.Parse" />.
/// </summary>
public sealed class RunCommandParseResult
{
/// <summary>
/// Command that matches the first word, or null if there is none.
/// </summary>
public RunCommandDefinition Command { get; init; }

/// <summary>
/// First word as typed.
/// </summary>
public string CommandText { get; init; } = string.Empty;

/// <summary>
/// Target (e.g. "10.0.0.1;10.0.0.2"), or null if there is none.
/// </summary>
public string Target { get; init; }

/// <summary>
/// Name of the profile ("@name"), or null if no profile is used. Empty if only "@" was typed.
/// </summary>
public string ProfileName { get; init; }

/// <summary>
/// Second argument (e.g. ports or DNS server), or null if there is none.
/// </summary>
public string Argument { get; init; }

/// <summary>
/// Type keyword in lowercase (e.g. "aaaa"), or null if there is none.
/// </summary>
public string Type { get; init; }

/// <summary>
/// Part of the input that is being typed.
/// </summary>
public RunCommandPosition Position { get; init; }

/// <summary>
/// Word that is being typed (empty after a space), used to filter the suggestions.
/// </summary>
public string CurrentWord { get; init; } = string.Empty;

/// <summary>
/// Input without the word that is being typed (e.g. "dns borntoberoot.net " for "dns borntoberoot.net aa"),
/// used to complete a suggestion.
/// </summary>
public string InputBeforeCurrentWord { get; init; } = string.Empty;

/// <summary>
/// Error, if the input can't be run.
/// </summary>
public RunCommandParseError Error { get; init; }

/// <summary>
/// Value the error refers to (e.g. the unknown command or argument).
/// </summary>
public string ErrorValue { get; init; }
}
Loading
Loading