Skip to content

Implement help <method-name>#300

Draft
liamgilligan wants to merge 1 commit intoConsensusJ:masterfrom
liamgilligan:walletd-help-implementation
Draft

Implement help <method-name>#300
liamgilligan wants to merge 1 commit intoConsensusJ:masterfrom
liamgilligan:walletd-help-implementation

Conversation

@liamgilligan
Copy link
Contributor

PR for #260

Currently filler text is being used, tests have been written/modified to account for new help behavior.

Copy link
Member

@msgilligan msgilligan left a comment

Choose a reason for hiding this comment

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

I know this is a draft, but I have a couple suggestions

return result(appName + " stopping");
}

private record helpMessages(String shortMessage, String longMessage){}
Copy link
Member

Choose a reason for hiding this comment

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

Classes in Java (and records are classes) start with a capital letter. And the name of a type representing a single help message should not be plural.

Copy link
Member

Choose a reason for hiding this comment

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

Also summary and details might be better names than shortMesage and longMessage.

import java.io.Closeable;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;
import java.util.HashMap;
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this import is no longer being used.

import org.consensusj.jsonrpc.JsonRpcError;
import org.consensusj.jsonrpc.JsonRpcStatusException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is still being used.

Copy link
Member

@msgilligan msgilligan left a comment

Choose a reason for hiding this comment

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

Additional comment.

return result(appName + " stopping");
}

private record helpMessages(String shortMessage, String longMessage){}
Copy link
Member

Choose a reason for hiding this comment

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

Also summary and details might be better names than shortMesage and longMessage.

@msgilligan
Copy link
Member

@liamgilligan See PR #303

@msgilligan
Copy link
Member

msgilligan commented Jan 26, 2026

Please rebase now that PR #303 is merged. Also see WIP PR #309.

We should add a JsonRpcHelp (or similar name) class a new .help subpackage of o.c.jsonrpc. Because this module is currently JDK 11, we can't use record, but we can create a record-like class and convert to a record for 0.8.0.

@liamgilligan liamgilligan force-pushed the walletd-help-implementation branch from 4b0f436 to c6e6377 Compare January 30, 2026 01:24
Added short summary and detailed help text, added and updated tests, and
added javadoc and copyright headers when applicable.
@liamgilligan liamgilligan force-pushed the walletd-help-implementation branch from c6e6377 to d7729fa Compare February 5, 2026 22:43
Copy link
Member

@msgilligan msgilligan left a comment

Choose a reason for hiding this comment

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

A few requested changes...

*/
package org.consensusj.jsonrpc.help;

public class JsonRpcHelp {
Copy link
Member

Choose a reason for hiding this comment

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

There should be class-level help here. It should note that this is a record-like structure and what it is used for.

*/
@Test
void helpMethodOneArg() throws IOException {
void helpMethodNoArg() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

help with no-arg should return a list of commands and their arguments, not an error code. The test and the server are both wrong.

stop
""";
void helpForStopMethod() throws IOException {
var expectedResult = "Initiate a graceful shutdown of the server.";
Copy link
Member

Choose a reason for hiding this comment

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

This should be the detailed help or at least spot check of the detailed help.

"echo message\n" +
"help\n" +
"stop\n";
private static final Map<String, JsonRpcHelp> helpMap = Map.of(
Copy link
Member

Choose a reason for hiding this comment

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

helpString above should be generated from this Map.

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.

2 participants