Skip to content
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

Add description to command registry (fixes #1119) #8

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Configuration for Release Drafter: https://github.com/toolmantim/release-drafter
name-template: $NEXT_PATCH_VERSION
tag-template: $NEXT_PATCH_VERSION
version-template: $MAJOR.$MINOR.$PATCH

# Emoji reference: https://gitmoji.carloscuesta.me/
categories:
- title: ":boom: Breaking changes"
labels:
- breaking
- title: 🚨 Removed
label: removed
- title: ":tada: Major features and improvements"
labels:
- major-enhancement
- major-rfe
- title: 🐛 Major bug fixes
labels:
- major-bug
- title: ⚠️ Deprecated
label: deprecated
- title: 🚀 New features and improvements
labels:
- enhancement
- feature
- rfe
- title: 🐛 Bug Fixes
labels:
- bug
- fix
- bugfix
- regression
- title: ":construction_worker: Changes for developers"
labels:
- developer
# Default label used by Dependabot
- title: 📦 Dependency updates
label: dependencies
- title: 📝 Documentation updates
label: documentation
- title: 👻 Maintenance
labels:
- chore
- internal
- maintenance
- title: 🔧 Build
label: build
- title: 🚦 Tests
labels:
- test
- tests
exclude-labels:
- reverted
- no-changelog
- skip-changelog
- invalid

change-template: '- $TITLE ([#$NUMBER]($URL)) @$AUTHOR'

template: |
<!-- Optional: add a release summary here -->
$CHANGES

45 changes: 45 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Release drafter
#

name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- master
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]
# pull_request_target event is required for autolabeler to support PRs from forks
# pull_request_target:
# types: [opened, reopened, synchronize]

permissions:
contents: read

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV

# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v6
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15 changes: 14 additions & 1 deletion console/src/main/java/org/jline/console/CommandRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.io.PrintStream;
import java.util.*;

import org.jline.reader.Candidate;
import org.jline.reader.impl.completer.SystemCompleter;
import org.jline.terminal.Terminal;

Expand Down Expand Up @@ -42,10 +43,22 @@ static SystemCompleter aggregateCompleters(CommandRegistry... commandRegistries)
*/
static SystemCompleter compileCompleters(CommandRegistry... commandRegistries) {
SystemCompleter out = aggregateCompleters(commandRegistries);
out.compile();
out.compile(s -> createCandidate(commandRegistries, s));
return out;
}

static Candidate createCandidate(CommandRegistry[] commandRegistries, String command) {
String group = null, desc = null;
for (CommandRegistry registry : commandRegistries) {
if (registry.hasCommand(command)) {
group = registry.name();
desc = registry.commandInfo(command).stream().findFirst().orElse(null);
break;
}
}
return new Candidate(command, command, group, desc, null, null, true);
}

/**
* Returns the name of this registry.
* @return the name of the registry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ private SystemCompleter _compileCompleters() {
}
local.add(customSystemCompleter);
out.add(local);
out.compile();
out.compile(s -> CommandRegistry.createCandidate(commandRegistries, s));
return out;
}

Expand Down
2 changes: 1 addition & 1 deletion console/src/main/java/org/jline/widget/TailTipWidgets.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public void setDescriptionCache(boolean cache) {
*/
public boolean tailtipComplete() {
if (doTailTip(LineReader.EXPAND_OR_COMPLETE)) {
if (lastBinding().equals("\t")) {
if ("\t".equals(lastBinding())) {
callWidget(LineReader.BACKWARD_CHAR);
reader.runMacro(key(reader.getTerminal(), InfoCmp.Capability.key_right));
}
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@
<jansi.version>2.4.1</jansi.version>
<juniversalchardet.version>1.0.3</juniversalchardet.version>
<sshd.version>2.14.0</sshd.version>
<easymock.version>5.4.0</easymock.version>
<easymock.version>5.5.0</easymock.version>
<junit.version>5.11.3</junit.version>
<gogo.runtime.version>1.1.6</gogo.runtime.version>
<gogo.jline.version>1.1.8</gogo.jline.version>
<slf4j.version>2.0.16</slf4j.version>
<findbugs.version>3.0.2</findbugs.version>
<groovy.version>4.0.23</groovy.version>
<groovy.version>4.0.24</groovy.version>
<ivy.version>2.5.2</ivy.version>
<graal.version>24.1.1</graal.version>
<graal.plugin.version>21.2.0</graal.plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
package org.jline.reader.impl.completer;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

import org.jline.reader.Candidate;
import org.jline.reader.Completer;
Expand All @@ -24,6 +26,7 @@
public class SystemCompleter implements Completer {
private Map<String, List<Completer>> completers = new HashMap<>();
private Map<String, String> aliasCommand = new HashMap<>();
private Map<String, String> descriptions = new HashMap<>();
private StringsCompleter commands;
private boolean compiled = false;

Expand Down Expand Up @@ -123,7 +126,7 @@ private Map<String, String> getAliases() {
return aliasCommand;
}

public void compile() {
public void compile(Function<String, Candidate> candidateBuilder) {
if (compiled) {
return;
}
Expand All @@ -139,7 +142,7 @@ public void compile() {
completers = compiledCompleters;
Set<String> cmds = new HashSet<>(completers.keySet());
cmds.addAll(aliasCommand.keySet());
commands = new StringsCompleter(cmds);
commands = new StringsCompleter(cmds.stream().map(candidateBuilder).collect(Collectors.toList()));
compiled = true;
}

Expand Down
Loading