Skip to content
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
284 changes: 284 additions & 0 deletions command-signatures/json/sdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
{
"name": "sdk",
"description": "SDKMAN! - The Software Development Kit Manager",
"subcommands": [
{
"name": [
"install",
"i"
],
"description": "Install a candidate version",
"args": [
{
"name": "candidate",
"description": "SDK candidate to install",
"generatorName": "sdk_candidates"
},
{
"name": "version",
"description": "Version to install (defaults to latest stable)",
"isOptional": true,
"generatorName": "sdk_versions"
},
{
"name": "local-path",
"description": "Path to a local installation",
"isOptional": true,
"template": "folders"
}
]
},
{
"name": [
"uninstall",
"rm"
],
"description": "Uninstall a candidate version",
"args": [
{
"name": "candidate",
"description": "SDK candidate to uninstall",
"generatorName": "sdk_installed_candidates"
},
{
"name": "version",
"description": "Version to uninstall",
"generatorName": "sdk_versions"
}
]
},
{
"name": [
"list",
"ls"
],
"description": "List available candidates or candidate versions",
"args": {
"name": "candidate",
"description": "SDK candidate to list versions for",
"isOptional": true,
"generatorName": "sdk_candidates"
}
},
{
"name": [
"use",
"u"
],
"description": "Use a candidate version in the current shell",
"args": [
{
"name": "candidate",
"description": "SDK candidate to use",
"generatorName": "sdk_installed_candidates"
},
{
"name": "version",
"description": "Version to use",
"generatorName": "sdk_versions"
}
]
},
{
"name": "config",
"description": "Edit the SDKMAN configuration"
},
{
"name": [
"default",
"d"
],
"description": "Set the default candidate version for all shells",
"args": [
{
"name": "candidate",
"description": "SDK candidate to set default for",
"generatorName": "sdk_installed_candidates"
},
{
"name": "version",
"description": "Version to set as default",
"isOptional": true,
"generatorName": "sdk_versions"
}
]
},
{
"name": [
"home",
"h"
],
"description": "Show the installation path of a candidate version",
"args": [
{
"name": "candidate",
"description": "SDK candidate",
"generatorName": "sdk_installed_candidates"
},
{
"name": "version",
"description": "Version to show path for",
"generatorName": "sdk_versions"
}
]
},
{
"name": [
"env",
"e"
],
"description": "Manage .sdkmanrc environment configuration",
"args": {
"name": "command",
"description": "Env subcommand",
"isOptional": true,
"suggestions": [
{
"name": "init",
"description": "Initialize a .sdkmanrc file in the current directory",
"type": "subcommand"
},
{
"name": "install",
"description": "Install SDKs specified in .sdkmanrc",
"type": "subcommand"
},
{
"name": "clear",
"description": "Reset SDKs to their default versions",
"type": "subcommand"
}
]
}
},
{
"name": [
"current",
"c"
],
"description": "Display the current version of a candidate or all candidates",
"args": {
"name": "candidate",
"description": "SDK candidate to show current version for",
"isOptional": true,
"generatorName": "sdk_installed_candidates"
}
},
{
"name": [
"upgrade",
"ug"
],
"description": "Show or perform upgrades for candidate versions",
"args": {
"name": "candidate",
"description": "SDK candidate to upgrade",
"isOptional": true,
"generatorName": "sdk_installed_candidates"
}
},
{
"name": [
"version",
"v"
],
"description": "Display the current version of SDKMAN"
},
{
"name": [
"broadcast",
"b"
],
"description": "Display the latest SDK release notifications"
},
{
"name": "help",
"description": "Show the SDKMAN help message",
"args": {
"name": "subcommand",
"description": "Subcommand to get help for",
"isOptional": true,
"suggestions": [
"install",
"uninstall",
"list",
"use",
"config",
"default",
"home",
"env",
"current",
"upgrade",
"version",
"broadcast",
"help",
"offline",
"selfupdate",
"update",
"flush"
]
}
},
{
"name": "offline",
"description": "Enable or disable offline mode",
"args": {
"name": "mode",
"description": "Enable or disable offline mode",
"isOptional": true,
"suggestions": [
{
"name": "enable",
"description": "Enable offline mode"
},
{
"name": "disable",
"description": "Disable offline mode"
}
]
}
},
{
"name": "selfupdate",
"description": "Update SDKMAN itself",
"args": {
"name": "force",
"description": "Force re-installation",
"isOptional": true,
"suggestions": [
{
"name": "force",
"description": "Force re-installation of SDKMAN"
}
]
}
},
{
"name": "update",
"description": "Refresh the candidate cache to discover new candidates"
},
{
"name": "flush",
"description": "Flush SDKMAN local state",
"args": {
"name": "target",
"description": "What to flush",
"isOptional": true,
"suggestions": [
{
"name": "tmp",
"description": "Flush the temporary folder"
},
{
"name": "metadata",
"description": "Flush the candidate metadata cache"
},
{
"name": "version",
"description": "Flush the cached SDKMAN version"
}
]
}
}
]
}
2 changes: 2 additions & 0 deletions command-signatures/src/generators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ mod powershell;
mod pyenv;
mod react_native;
mod screen;
mod sdk;
mod ssh;
mod systemctl;
mod tar;
Expand Down Expand Up @@ -98,6 +99,7 @@ pub fn dynamic_command_signature_data() -> HashMap<String, DynamicCompletionData
tmux::generator(),
node::generator(),
screen::generator(),
sdk::generator(),
powershell::get_help_generator(),
powershell::get_process_generator(),
powershell::debug_process_generator(),
Expand Down
73 changes: 73 additions & 0 deletions command-signatures/src/generators/sdk.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
use warp_completion_metadata::{
CommandBuilder, CommandSignatureGenerators, Generator, GeneratorResultsCollector, Suggestion,
};

pub fn generator() -> CommandSignatureGenerators {
CommandSignatureGenerators::new("sdk")
.add_generator(
"sdk_candidates",
Generator::script(
CommandBuilder::single_command("cat ~/.sdkman/var/candidates"),
|output| {
output
.trim()
.split(',')
.filter(|s| !s.is_empty())
.map(|candidate| {
Suggestion::with_description(candidate.trim(), "SDK candidate")
})
.collect_unordered_results()
},
),
)
.add_generator(
"sdk_installed_candidates",
Generator::script(
CommandBuilder::single_command("ls -1 ~/.sdkman/candidates"),
|output| {
output
.trim()
.lines()
.filter(|s| !s.is_empty())
.map(|candidate| {
Suggestion::with_description(candidate.trim(), "Installed candidate")
})
.collect_unordered_results()
},
),
)
.add_generator(
"sdk_versions",
Generator::command_from_tokens(
|tokens, has_trailing_whitespace, _| {
// The candidate name is the token immediately before the version position.
// With trailing whitespace, the last completed token is the candidate.
// Without trailing whitespace, the second-to-last token is the candidate.
let candidate = if has_trailing_whitespace {
tokens.last().copied()
} else {
tokens.get(tokens.len().saturating_sub(2)).copied()
};
match candidate {
Some(candidate) if !candidate.is_empty() && !candidate.starts_with('-') => {
CommandBuilder::single_command(format!(
"ls -1 ~/.sdkman/candidates/{}/",
candidate
))
}
_ => CommandBuilder::single_command("echo"),
}
},
|output| {
output
.trim()
.lines()
.filter(|s| !s.is_empty() && *s != "current")
.map(|version| {
Suggestion::with_description(version.trim(), "Installed version")
})
.collect_unordered_results()
},
),
)
}
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading