feat: cmd to print debug information (#787)

This commit is contained in:
James Hegedus 2020-08-24 10:55:41 +10:00 committed by GitHub
parent d37e99a21e
commit 8ca2af3316
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 6 deletions

View File

@ -32,14 +32,13 @@ Tell us what happened instead
### Environment
**OS**:
<!-- Copy the output of `asdf info` here -->
```shell
**asdf version**:
```
**asdf plugins affected (if relevant)**:
**asdf plugins installed**:
**Screenshots**
If applicable, add screenshots to help explain your problem.

View File

@ -30,6 +30,7 @@ asdf_commands=( # 'asdf help' lists commands with help text
# utils
'exec:executes the command shim for the current version'
'env:prints or runs an executable under a command environment'
'info:print os, shell and asdf debug information'
'reshim:recreate shims for version of a package'
'shim:shim management sub-commands'
'shim-versions:list for given command which plugins and versions provide it'

View File

@ -56,7 +56,7 @@ _asdf() {
fi
;;
*)
local cmds='current global help install list list-all local plugin-add plugin-list plugin-list-all plugin-remove plugin-update reshim shell uninstall update where which '
local cmds='current global help install list list-all local plugin-add plugin-list plugin-list-all plugin-remove plugin-update reshim shell uninstall update where which info'
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$cmds" -- "$cur"))
;;

View File

@ -132,4 +132,5 @@ complete -f -c asdf -n '__fish_asdf_using_command shell; and test (count (comman
# misc
complete -f -c asdf -n '__fish_asdf_needs_command' -l "help" -d "Displays help"
complete -f -c asdf -m '__fish_asdf_needs_command' -l "info" -d "Print OS, Shell and ASDF debug information"
complete -f -c asdf -n '__fish_asdf_needs_command' -l "version" -d "Displays asdf version"

View File

@ -45,6 +45,7 @@ UTILS
asdf exec <command> [args...] Executes the command shim for current version
asdf env <command> [util] Runs util (default: `env`) inside the
environment used for command shim execution.
asdf info Print OS, Shell and ASDF debug information.
asdf reshim <name> <version> Recreate shims for version of a package
asdf shim-versions <command> List the plugins and versions that
provide a command

View File

@ -0,0 +1,11 @@
# -*- sh -*-
info_command() {
printf "%s:\n%s\n\n" "OS" "$(uname -a)"
printf "%s:\n%s\n\n" "SHELL" "$($SHELL --version)"
printf "%s:\n%s\n\n" "ASDF VERSION" "$(asdf_version)"
printf "%s:\n%s\n\n" "ASDF ENVIRONMENT VARIABLES" "$(env | grep -E "ASDF_DIR|ASDF_DATA_DIR|ASDF_CONFIG_FILE|ASDF_DEFAULT_TOOL_VERSIONS_FILENAME")"
printf "%s:\n%s\n\n" "ASDF INSTALLED PLUGINS" "$(asdf plugin list --urls)"
}
info_command "$@"

27
test/info_command.bats Normal file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env bats
load test_helpers
setup() {
setup_asdf_dir
install_dummy_plugin
install_dummy_legacy_plugin
run asdf install dummy 1.0
run asdf install dummy 1.1
PROJECT_DIR=$HOME/project
mkdir $PROJECT_DIR
}
teardown() {
clean_asdf_dir
}
@test "info should show os, shell and asdf debug information" {
cd $PROJECT_DIR
run asdf info
[ "$status" -eq 0 ]
# TODO: Assert asdf info output is printed
}