53 lines
2.2 KiB
Java
53 lines
2.2 KiB
Java
package com.agenticcode.cli;
|
|
|
|
import org.jspecify.annotations.Nullable;
|
|
import picocli.CommandLine.Command;
|
|
import picocli.CommandLine.Option;
|
|
import picocli.CommandLine.Parameters;
|
|
|
|
/**
|
|
* Searches for an identifier across all ingested modules, or lists all identifiers
|
|
* if no name is given.
|
|
*/
|
|
@Command(name = "search-identifier", mixinStandardHelpOptions = true, description = "Search for an identifier across all modules, or list all identifiers")
|
|
final class SearchIdentifierCommand extends AbstractProjectCommand {
|
|
|
|
@Parameters(index = "0", arity = "0..1", description = "Identifier name; a leading Natural sigil (# & +) is ignored (omit to list all identifiers)")
|
|
@Nullable String name;
|
|
|
|
@Option(names = "--type", description = "Node type filter (MODULE, FUNCTION, VARIABLE, DATA_STRUCTURE, DB_TABLE)")
|
|
@Nullable String type;
|
|
|
|
@Option(names = "--module", description = "Scope to nodes of this module (by name)")
|
|
@Nullable String module;
|
|
|
|
@Option(names = "--priority-module", description = "Pin this module's matches to the front (no filtering) so its local declaration survives the limit when a name recurs across modules")
|
|
@Nullable String priorityModule;
|
|
|
|
@Option(names = "--source-file", description = "Scope to this exact source file (relative path)")
|
|
@Nullable String sourceFile;
|
|
|
|
@Option(names = "--limit", description = "Max items to return")
|
|
int limit = -1;
|
|
|
|
@Option(names = "--offset", description = "Items to skip")
|
|
int offset = -1;
|
|
|
|
@Override
|
|
public Integer call() throws Exception {
|
|
try {
|
|
String path = projectPath() + "/search/identifier";
|
|
path = appendQuery(path, "name", name);
|
|
path = appendQuery(path, "type", type);
|
|
path = appendQuery(path, "module", module);
|
|
path = appendQuery(path, "priorityModule", priorityModule);
|
|
path = appendQuery(path, "sourceFile", sourceFile);
|
|
path = appendQuery(appendQuery(path, "limit", limit), "offset", offset);
|
|
return printResponse(apiClient().get(path));
|
|
} catch (IllegalStateException e) {
|
|
System.err.println(e.getMessage());
|
|
return 1;
|
|
}
|
|
}
|
|
}
|