From 8ca2af3316be03f980598c5dbcb8152b6b56e96a Mon Sep 17 00:00:00 2001 From: James Hegedus Date: Mon, 24 Aug 2020 10:55:41 +1000 Subject: [PATCH] feat: cmd to print debug information (#787) --- .github/ISSUE_TEMPLATE/bug_report.md | 7 +++---- completions/_asdf | 1 + completions/asdf.bash | 2 +- completions/asdf.fish | 1 + help.txt | 3 ++- lib/commands/command-info.bash | 11 +++++++++++ test/info_command.bats | 27 +++++++++++++++++++++++++++ 7 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 lib/commands/command-info.bash create mode 100644 test/info_command.bats diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index a5af3f4f..001e2b95 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -32,14 +32,13 @@ Tell us what happened instead ### Environment -**OS**: + +```shell -**asdf version**: +``` **asdf plugins affected (if relevant)**: -**asdf plugins installed**: - **Screenshots** If applicable, add screenshots to help explain your problem. diff --git a/completions/_asdf b/completions/_asdf index c2bc2598..c8a90864 100755 --- a/completions/_asdf +++ b/completions/_asdf @@ -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' diff --git a/completions/asdf.bash b/completions/asdf.bash index b3fc45d3..260488b6 100644 --- a/completions/asdf.bash +++ b/completions/asdf.bash @@ -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")) ;; diff --git a/completions/asdf.fish b/completions/asdf.fish index 4626094c..75f4b481 100644 --- a/completions/asdf.fish +++ b/completions/asdf.fish @@ -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" diff --git a/help.txt b/help.txt index fd832bb2..a880ae42 100644 --- a/help.txt +++ b/help.txt @@ -14,7 +14,7 @@ asdf plugin update --all Update all plugins MANAGE PACKAGES asdf install Install all the package versions listed - in the .tool-versions file + in the .tool-versions file asdf install Install one tool at the version specified in the .tool-versions file asdf install Install a specific version of a package @@ -45,6 +45,7 @@ UTILS asdf exec [args...] Executes the command shim for current version asdf env [util] Runs util (default: `env`) inside the environment used for command shim execution. +asdf info Print OS, Shell and ASDF debug information. asdf reshim Recreate shims for version of a package asdf shim-versions List the plugins and versions that provide a command diff --git a/lib/commands/command-info.bash b/lib/commands/command-info.bash new file mode 100644 index 00000000..c61ee603 --- /dev/null +++ b/lib/commands/command-info.bash @@ -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 "$@" diff --git a/test/info_command.bats b/test/info_command.bats new file mode 100644 index 00000000..4fb32151 --- /dev/null +++ b/test/info_command.bats @@ -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 +}