Skip to content

Conversation

vLuckyyy
Copy link
Member

Using MOST_RELEVANT:
image

Using DETAILED:
image

Video:

2025-09-16.00-07-59.mp4

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a configurable way to display invalid command usage messages, which is a great enhancement for user experience. The implementation is well-structured, with new settings neatly organized into their own package and integrated into the main configuration. The use of an interface for the settings is a good design choice for decoupling. I have one suggestion to make the code in the handler slightly more modern and concise.

Comment on lines +59 to 70
int limit = Math.max(1, this.invalidUsageSettings.detailedMaxEntries());
int shown = 0;

for (String schema : schematic.all()) {
this.noticeService.viewer(viewer, translation -> translation.argument().usageMessageEntry(), SCHEME.toFormatter(schema));
if (shown++ >= limit) {
break;
}
this.noticeService.viewer(
viewer,
translation -> translation.argument().usageMessageEntry(),
SCHEME.toFormatter(schema));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The loop for sending usage hints can be simplified by using the Java Stream API. This approach is more concise, expressive, and less prone to manual indexing errors.

        schematic.all().stream()
            .limit(Math.max(1, this.invalidUsageSettings.detailedMaxEntries()))
            .forEach(schema -> this.noticeService.viewer(
                viewer,
                translation -> translation.argument().usageMessageEntry(),
                SCHEME.toFormatter(schema)
            ));

this.noticeService.viewer(viewer, translation -> translation.argument().usageMessageHead());
}

int limit = Math.max(1, this.invalidUsageSettings.detailedMaxEntries());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int limit = Math.max(1, this.invalidUsageSettings.detailedMaxEntries());
int limit = Math.max(1, this.invalidUsageSettings.detailedMaxEntries());
schematic.all().stream()
.limit(limit)
.forEach(schema -> this.noticeService.viewer(
viewer,
translation -> translation.argument().usageMessageEntry(),
SCHEME.toFormatter(schema)));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pardon nie widziałem podpowiedzi bota xD

Comment on lines +20 to +28
@Comment({
"# When usageHintMode is DETAILED: maximum number of usages to show in the list."
})
public int detailedMaxEntries = 5;

@Comment({
"# When usageHintMode is DETAILED: whether to show the usage header before the list."
})
public boolean detailedShowHeader = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Comment({
"# When usageHintMode is DETAILED: maximum number of usages to show in the list."
})
public int detailedMaxEntries = 5;
@Comment({
"# When usageHintMode is DETAILED: whether to show the usage header before the list."
})
public boolean detailedShowHeader = true;
@Comment({
"# Applies ONLY when usageHintMode = DETAILED.",
"# Maximum number of usages to show in the list."
})
public int detailedMaxEntries = 5;
@Comment({
"# Applies ONLY when usageHintMode = DETAILED.",
"# Whether to show the usage header before the list."
})
public boolean detailedShowHeader = true;

Copy link
Member

@Jakubk15 Jakubk15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jest git imo

@SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"})
@Getter
@Accessors(fluent = true)
public class InvalidUsageConfig extends OkaeriConfig implements InvalidUsageSettings {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to define standards regarding configs in future meeting - why are we having public fields despite having generated getters?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Limit InvalidUsageHandler from LiteCommands to the most relevant one (LiteCommands usage generator)
5 participants