-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add CommandHelpService #14
Draft
Foxtrek64
wants to merge
16
commits into
Remora:main
Choose a base branch
from
Foxtrek64:CommandInfoService
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3831201
Add HiddenFromHelpAttribute
Foxtrek64 c7c87fb
Implement information types
Foxtrek64 1525d24
Migrate Description to IChildNode
Foxtrek64 b7af3d3
Add description to CommandNode
Foxtrek64 ced9508
Add description to command node builder
Foxtrek64 4b30d92
Add HiddenFromHelpComment to group info
Foxtrek64 6c10632
Add RootInfo
Foxtrek64 343f55f
Initial design
Foxtrek64 9799129
Add initial form to CommandHelpService
Foxtrek64 8a6fae0
Change to using IConditionInfo
Foxtrek64 3b5cf79
Add ConditionPropertyInfo
Foxtrek64 d6f89dc
Remove CommandArgumentInfo
Foxtrek64 85fb2a7
First attempt at a FindInfo method
Foxtrek64 495aa01
Default to always build child groups
Foxtrek64 6c1ed41
Add attribute usage to HiddenFromHelpAttribute
Foxtrek64 5cdca61
Save changes
Foxtrek64 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// HiddenFromHelpAttribute.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) 2017 Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System; | ||
|
||
namespace Remora.Commands.Attributes | ||
{ | ||
/// <summary> | ||
/// Marks a command or group as being hidden from the help service. | ||
/// </summary> | ||
/// <remarks> | ||
/// This attribute represents a request to be hidden. The implementing | ||
/// service may or may not respect this request. | ||
/// </remarks> | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] | ||
public sealed class HiddenFromHelpAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Gets a comment provided by the developer, if any. | ||
/// </summary> | ||
public string? Comment { get; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="HiddenFromHelpAttribute"/> class. | ||
/// </summary> | ||
/// <param name="comment">A comment describing why this is hidden or any relevant notes. May be displayed by the help service.</param> | ||
public HiddenFromHelpAttribute(string? comment = null) | ||
{ | ||
Comment = comment; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// CommandBranch.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) 2017 Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using OneOf; | ||
|
||
namespace Remora.Commands.CommandInformation | ||
{ | ||
/// <inheritdoc /> | ||
public sealed record CommandBranch | ||
( | ||
IGroupInfo GroupInfo, | ||
OneOf<ICommandInfo, ICommandInfo[]> Commands | ||
) : ICommandBranch; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// CommandInfo.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) 2017 Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System.Collections.Generic; | ||
using System.Reflection; | ||
|
||
namespace Remora.Commands.CommandInformation | ||
{ | ||
/// <inheritdoc /> | ||
public sealed record CommandInfo | ||
( | ||
string Name, | ||
string? Description, | ||
IReadOnlyList<string> Aliases, | ||
bool Hidden, | ||
string? HiddenFromHelpComment, | ||
IReadOnlyList<IConditionInfo> Conditions, | ||
IReadOnlyList<ParameterInfo> Arguments | ||
) : ICommandInfo; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// ConditionInfo.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) 2017 Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Remora.Commands.CommandInformation | ||
{ | ||
/// <inheritdoc /> | ||
public sealed record ConditionInfo(string Name, string? Description, IReadOnlyList<IConditionPropertyInfo> ConditionProperties) : IConditionInfo; | ||
} |
31 changes: 31 additions & 0 deletions
31
Remora.Commands/CommandInformation/ConditionPropertyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// ConditionPropertyInfo.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) 2017 Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System; | ||
using JetBrains.Annotations; | ||
|
||
namespace Remora.Commands.CommandInformation | ||
{ | ||
/// <inheritdoc /> | ||
[PublicAPI] | ||
public sealed record ConditionPropertyInfo(string Name, bool CanRead, bool CanWrite, Type PropertyType, object? Value) : IConditionPropertyInfo; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// GroupInfo.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) 2017 Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Remora.Commands.CommandInformation | ||
{ | ||
/// <inheritdoc /> | ||
public sealed record GroupInfo | ||
( | ||
string Name, | ||
string? Description, | ||
IReadOnlyList<string> Aliases, | ||
bool Hidden, | ||
string? HiddenFromHelpComment, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
IReadOnlyList<ICommandInfo> Commands, | ||
IReadOnlyList<IGroupInfo> ChildGroups | ||
) : IGroupInfo; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// ICommandBranch.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) 2017 Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using OneOf; | ||
|
||
namespace Remora.Commands.CommandInformation | ||
{ | ||
/// <summary> | ||
/// Represents a branch within the command system. | ||
/// </summary> | ||
public interface ICommandBranch | ||
{ | ||
/// <summary> | ||
/// Gets the command group which was found at the level searched. | ||
/// </summary> | ||
IGroupInfo GroupInfo { get; } | ||
|
||
/// <summary> | ||
/// Gets the command or all overloaded commands found at the level searched. | ||
/// </summary> | ||
OneOf<ICommandInfo, ICommandInfo[]> Commands { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// ICommandInfo.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) 2017 Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System.Collections.Generic; | ||
using System.Reflection; | ||
|
||
namespace Remora.Commands.CommandInformation | ||
{ | ||
/// <summary> | ||
/// Contains information about a specific command. | ||
/// </summary> | ||
public interface ICommandInfo | ||
{ | ||
/// <summary> | ||
/// Gets the name of the command. | ||
/// </summary> | ||
string Name { get; } | ||
|
||
/// <summary> | ||
/// Gets the command's description, if any. | ||
/// </summary> | ||
string? Description { get; } | ||
|
||
/// <summary> | ||
/// Gets a read-only list of the command's aliases. | ||
/// </summary> | ||
IReadOnlyList<string> Aliases { get; } | ||
|
||
/// <summary> | ||
/// Gets a value indicating whether the command was requested to be hidden from help commands. | ||
/// </summary> | ||
bool Hidden { get; } | ||
|
||
/// <summary> | ||
/// Gets a comment describing why the command is hidden. | ||
/// </summary> | ||
string? HiddenFromHelpComment { get; } | ||
|
||
/// <summary> | ||
/// Gets a read-only list of any command conditions. | ||
/// </summary> | ||
IReadOnlyList<IConditionInfo> Conditions { get; } | ||
|
||
/// <summary> | ||
/// Gets a read-only list of any command arguments. | ||
/// </summary> | ||
IReadOnlyList<ParameterInfo> Arguments { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// IConditionInfo.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) 2017 Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Remora.Commands.CommandInformation | ||
{ | ||
/// <summary> | ||
/// Contains information about a specific command condition. | ||
/// </summary> | ||
public interface IConditionInfo | ||
{ | ||
/// <summary> | ||
/// Gets the display name of the condition. | ||
/// </summary> | ||
string Name { get; } | ||
|
||
/// <summary> | ||
/// Gets the description of the condition, if any. | ||
/// </summary> | ||
string? Description { get; } | ||
|
||
/// <summary> | ||
/// Gets a list of properties belonging to the condition this type represents. | ||
/// </summary> | ||
IReadOnlyList<IConditionPropertyInfo> ConditionProperties { get; } | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the naming of this property - could we come up with a better name?