{"id":21201588,"url":"https://github.com/k-boyle/oktane","last_synced_at":"2025-06-24T00:31:50.613Z","repository":{"id":42877553,"uuid":"335373146","full_name":"k-boyle/Oktane","owner":"k-boyle","description":"A high performance Java command framework","archived":false,"fork":false,"pushed_at":"2025-06-10T12:11:10.000Z","size":6293,"stargazers_count":9,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-23T09:13:19.174Z","etag":null,"topics":["hacktoberfest","hacktoberfest2021","java","performance"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/k-boyle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-02T17:41:56.000Z","updated_at":"2022-01-27T17:07:35.000Z","dependencies_parsed_at":"2023-11-17T03:19:35.156Z","dependency_job_id":"27492118-8009-4437-b06c-fc9ace02d80b","html_url":"https://github.com/k-boyle/Oktane","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/k-boyle/Oktane","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-boyle%2FOktane","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-boyle%2FOktane/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-boyle%2FOktane/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-boyle%2FOktane/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k-boyle","download_url":"https://codeload.github.com/k-boyle/Oktane/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-boyle%2FOktane/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261582645,"owners_count":23180633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","hacktoberfest2021","java","performance"],"created_at":"2024-11-20T20:09:56.579Z","updated_at":"2025-06-24T00:31:50.592Z","avatar_url":"https://github.com/k-boyle.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Quality Gate Status](https://img.shields.io/sonar/quality_gate/k-boyle_Oktane?server=https%3A%2F%2Fsonarcloud.io\u0026style=for-the-badge)](https://sonarcloud.io/dashboard?id=k-boyle_Oktane)\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.k-boyle/Oktane?label=stable\u0026style=for-the-badge)](https://search.maven.org/artifact/com.github.k-boyle/Oktane)\n[![OSS Snapshot](https://img.shields.io/nexus/s/com.github.k-boyle/Oktane?label=snapshot\u0026server=https%3A%2F%2Foss.sonatype.org%2F\u0026style=for-the-badge)](https://oss.sonatype.org/#nexus-search;quick~oktane)\n\nOktane is a high performance, highly configurable Java command framework used to map strings to methods, and execute them.\nIt is built upon the [Reactor](https://projectreactor.io/) framework to allow easy integration with reactive projects, such as [Discord4J](https://github.com/Discord4J/Discord4J).\n\nInspired by [Qmmands](https://github.com/quahu/qmmands).\n\nGuides can be found on the [Wiki](https://github.com/k-boyle/Oktane/wiki), Javadocs on [gh-pages](https://k-boyle.github.io/Oktane/), example usage can be seen in the OktaneExample module, and an example using Discord4J and Spring [here](https://github.com/k-boyle/degenerate).\n\n# Usage #\n\n**Context Creation**\n\nYour command context is a standard pojo used to pass contextual data into your commands. `BeanProvider` is a service container with the interface providing a default implementations.\n```java\npublic class OktaneCommandContext extends CommandContext {\n    private final String user;\n    \n    public OktaneCommandContext(String user, BeanProvider beanProvider) {\n        super(beanProvider);\n        this.user = user;\n    }\n    \n    public String user() {\n        return user;\n    }\n}\n```\n\n**Module Creation**\n\nTo define a class as a module the class just needs to extend `ModuleBase\u003cT\u003e`.\nThe `@Aliases` annotation is used to force an annotation processor to run.\nMethods that are **public** and return `CommandResult` or `Mono\u003cCommandResult\u003e` are designated as commands.\nWhen a class extends `ModuleBase\u003cT\u003e` a class will be generated that corresponds to each command method which will be used to invoke the commands at runtime,\nthis approach means that there is no overhead vs a direct method call,\nif the module is not annotated then reflection will be used to invoke the methods (this is some magnitudes slower).\nThe `Aliases` annotation tells the `CommandHandler` what strings to map to this method.\n\n```java\npublic class OktaneCommandModule extends ModuleBase\u003cOktaneCommandContext\u003e {\n    @Aliases({\"echo\", \"e\"})\n    public CommandResult pingPong(@Remainder String input) {\n        return message(context().user() + \" said: \" + input);\n    }\n    \n    @Aliases({\"ping\", \"p\"})\n    public Mono\u003cCommandResult\u003e ping() {\n        return sendWebRequest()\n            .map(statusCode -\u003e message(\"Got response: \" + statusCode));\n    }\n}\n```\n\n**CommandHandler Creation**\n\nThe command handler is your interface for interacting with your commands.\n```java\npublic CommandHandler\u003cOktaneCommandContext\u003e commandHandler() {\n    return CommandHandler.\u003cOktaneCommandContext\u003ebuilder()\n        .withModule(OktaneCommandModule.class)\n        .build();\n}    \n```\n\n**Command Invocation**\n\nTo invoke a command you simply call to call `excute` on the command handler, pass it your command context, and the string input to parse.\n```java\nOktaneCommandContext context = new OktaneCommandContext(\"Kieran\", BeanProvider.get());\nMono\u003cResult\u003e result = commandHandlder.execute(\"echo Oktane is really cool :)\", context);\nresult.ofType(CommandMessageResult.class)\n    .map(CommandMessageResult::message)\n    .subscribe(message -\u003e System.out.println(message));\n```\n\n**Granular Configuration**\n\nModules and commands can be configured a fair amount.\n\n```java\n@Name(\"My Module\")                                                              // Can be used in help displays, all the modules and commands can be accessed via\n                                                                                // CommandHandler#modules, and CommandHandler#commands \n@Description(\"This is a command module\")                                        // Can be used in help displays\n@Aliases({\"a\", \"b\"})                                                            // commands inside a group must have the group prefix to execute, e.g. \"a echo\"\n@Singleton                                                                      // Makes the module a singleton (transient by default)\n@Synchronised                                                                   // Makes it so that all commands in the module are synchronised on a shared lock\npublic class OktaneCommandModule extends ModuleBase\u003cOktaneCommandContext\u003e {\n    \n    @Name(\"Echo Command\")                                                       // Can be used in help displays\n    @Description(\"Echos input\")                                                 // Can be used in help displays\n    @Aliases({\"echo\", \"e\"})                                                     // Defines the different aliases that can invoke the command\n    @Synchronised                                                               // Makes it so that the command is locally synchronised (public CommandResult synchronised ...)\n    public CommandResult pingPong(\n            @Name(\"User Input\")                                                 // Can be used in help displays       \n            @Description(\"The input to echo\")                                   // Can be used in help displays\n            @Remainder                                                          // Denotes the parameter as a remainder, so all the remaining text left to parse\n                                                                                // will be passed into this parameter. There can only be one remainder, and it\n                                                                                // must be the last parameter\n            String input) {\n        return message(context().user() + \" said: \" + input);\n    }\n}\n```\n\n**Type Parsing**\n\nOktane supports parsing all the primitive types, see `PrimitiveTypeParserFactory`, and allowing a user to define their own.\nType parsers are added during the `CommandHandler` building stage using the `withTypeParser` method.\n```java\npublic class UserTypeParser implements TypeParser\u003cUser\u003e {\n    @Override\n    public Mono\u003cTypeParserResult\u003cT\u003e\u003e parse(CommandContext context, Command command, String input) {\n        return context.beanProvider().get(UserService.class)\n            .getUser(input)\n            .map(this::success)\n            .switchOnEmpty(failure(\"Failed to parse %s as a valid user\", input).mono());\n    }\n} \n```\n\n**Dependency Injection**\n\nBeans can be injected into module using the `BeanProvider`, any constructor arguments will be passed into the module on instantiation, the `CommandHandler`\nwill inject itself and does not need to be added to a provider.\n```java\npublic class OktaneCommandModule extends ModuleBase\u003cOktaneCommandContext\u003e {\n    private final CommandHandler\u003cOktaneCommandContext\u003e commandHandler;\n    private final UserService userService;\n    \n    public OktaneCommandModule(\n            CommandHandler\u003cOktaneCommandContext\u003e commandHandler,\n            UserService userService) {\n        this.commandHandler = commandHandler;\n        this.userService = userService;\n    }\n    \n    @Aliases({\"commands\", \"c\"})\n    public CommandResult commandCount() {\n        return message(\"There are \" + commandHandler.commands().count() + \" commands\");\n    }\n    \n    @Aliases({\"users\"})\n    public Mono\u003cCommandResult\u003e listUsers() {\n        return userService.getAll()\n            .map(users -\u003e message(users));\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-boyle%2Foktane","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk-boyle%2Foktane","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-boyle%2Foktane/lists"}