Skip to content

Commit

Permalink
playground tools install-vscode-extension
Browse files Browse the repository at this point in the history
  • Loading branch information
vdesabou committed Jun 6, 2024
1 parent 047259d commit 6d501b4
Show file tree
Hide file tree
Showing 7 changed files with 365 additions and 367 deletions.
2 changes: 1 addition & 1 deletion reproduction-models
358 changes: 179 additions & 179 deletions scripts/cli/completions.bash

Large diffs are not rendered by default.

301 changes: 151 additions & 150 deletions scripts/cli/playground
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ playground_usage() {
printf " %s Show help about a command\n" "$(green "help") "
printf " %s 🗺️ Show a status\n" "$(green "status") "
printf " %s ⚙️ Configure CLI\n" "$(green "config") "
printf " %s 🪄 Install a slightly modified version of \"Shell Script Command Completion\" Visual Studio Code extension (https://marketplace.visualstudio.com/items?itemName=tetradresearch.vscode-h2o)\n" "$(green "install-vscode-extension") "
echo
printf "%s\n" "$(bold "Run commands:")"
printf " %s 🕹️ Run any example !\n" "$(green "run") "
Expand Down Expand Up @@ -91,6 +90,7 @@ playground_usage() {
echo
printf "%s\n" "$(bold "Tools commands:")"
printf " %s 🧰 Tools commands\n" "$(green "tools") "
printf " %s 🪄 Install a slightly modified version of \"Shell Script Command Completion\" Visual Studio Code extension (https://marketplace.visualstudio.com/items?itemName=tetradresearch.vscode-h2o)\n" "$(green "tools install-vscode-extension") "
printf " %s 🔐 Read provided avro file\n" "$(green "tools read-avro-file") "
printf " %s 🔐 Read provided parquet file\n" "$(green "tools read-parquet-file") "
echo
Expand Down Expand Up @@ -1564,43 +1564,6 @@ playground_config_clipboard_usage() {
fi
}

# :command.usage
playground_install_vscode_extension_usage() {
if [[ -n $long_usage ]]; then
printf "playground install-vscode-extension\n"
echo

printf " 🪄 Install a slightly modified version of \"Shell Script Command Completion\"\n Visual Studio Code extension\n (https://marketplace.visualstudio.com/items?itemName=tetradresearch.vscode-h2o)\n \n After installation, install \"playground\" command:\n \n * Go on a .sh file\n \n * Type Ctrl+Shift+P (or ⌘+⇧+P on macOS) and choose \"Shell Completion: Load\n Command Spec (experimental)\"\" and then type \"playground\"\n \n 👉 Check documentation\n https://kafka-docker-playground.io/#/cli?id=%%f0%%9f%%aa%%84-setup-shell-script-command-completion-visual-studio-code-extension\n"
echo

else
printf "playground install-vscode-extension - 🪄 Install a slightly modified version of \"Shell Script Command Completion\" Visual Studio Code extension (https://marketplace.visualstudio.com/items?itemName=tetradresearch.vscode-h2o)\n"
echo

fi

printf "%s\n" "$(bold "== Usage ==")"
printf " playground install-vscode-extension\n"
printf " playground install-vscode-extension --help | -h\n"
echo

# :command.long_usage
if [[ -n $long_usage ]]; then
printf "%s\n" "$(bold "== Options ==")"

# :command.usage_fixed_flags
printf " %s\n" "$(magenta "--help, -h")"
printf " Show this help\n"
echo

# :command.usage_examples
printf "%s\n" "$(bold "Examples")"
printf " playground install-vscode-extension\n"
echo

fi
}

# :command.usage
playground_run_usage() {
if [[ -n $long_usage ]]; then
Expand Down Expand Up @@ -3289,8 +3252,9 @@ playground_tools_usage() {
echo
# :command.usage_commands
printf "%s\n" "$(bold "== Commands ==")"
printf " %s 🔐 Read provided avro file\n" "$(green "read-avro-file") "
printf " %s 🔐 Read provided parquet file\n" "$(green "read-parquet-file")"
printf " %s 🪄 Install a slightly modified version of \"Shell Script Command Completion\" Visual Studio Code extension (https://marketplace.visualstudio.com/items?itemName=tetradresearch.vscode-h2o)\n" "$(green "install-vscode-extension")"
printf " %s 🔐 Read provided avro file\n" "$(green "read-avro-file") "
printf " %s 🔐 Read provided parquet file\n" "$(green "read-parquet-file") "
echo

# :command.long_usage
Expand All @@ -3305,6 +3269,43 @@ playground_tools_usage() {
fi
}

# :command.usage
playground_tools_install_vscode_extension_usage() {
if [[ -n $long_usage ]]; then
printf "playground tools install-vscode-extension\n"
echo

printf " 🪄 Install a slightly modified version of \"Shell Script Command Completion\"\n Visual Studio Code extension\n (https://marketplace.visualstudio.com/items?itemName=tetradresearch.vscode-h2o)\n \n After installation, install \"playground\" command:\n \n * Go on a .sh file\n \n * Type Ctrl+Shift+P (or ⌘+⇧+P on macOS) and choose \"Shell Completion: Load\n Command Spec (experimental)\"\" and then type \"playground\"\n \n 👉 Check documentation\n https://kafka-docker-playground.io/#/cli?id=%%f0%%9f%%aa%%84-setup-shell-script-command-completion-visual-studio-code-extension\n"
echo

else
printf "playground tools install-vscode-extension - 🪄 Install a slightly modified version of \"Shell Script Command Completion\" Visual Studio Code extension (https://marketplace.visualstudio.com/items?itemName=tetradresearch.vscode-h2o)\n"
echo

fi

printf "%s\n" "$(bold "== Usage ==")"
printf " playground tools install-vscode-extension\n"
printf " playground tools install-vscode-extension --help | -h\n"
echo

# :command.long_usage
if [[ -n $long_usage ]]; then
printf "%s\n" "$(bold "== Options ==")"

# :command.usage_fixed_flags
printf " %s\n" "$(magenta "--help, -h")"
printf " Show this help\n"
echo

# :command.usage_examples
printf "%s\n" "$(bold "Examples")"
printf " playground tools install-vscode-extension\n"
echo

fi
}

# :command.usage
playground_tools_read_avro_file_usage() {
if [[ -n $long_usage ]]; then
Expand Down Expand Up @@ -13354,55 +13355,6 @@ playground_config_clipboard_command() {
playground config set clipboard "${args[enabled]}"
}

# :command.function
playground_install_vscode_extension_command() {
# src/commands/install-vscode-extension.sh
tmp_dir=$(mktemp -d -t pg-XXXXXXXXXX)
if [ -z "$PG_VERBOSE_MODE" ]
then
trap 'rm -rf $tmp_dir' EXIT
else
log "🐛📂 not deleting tmp dir $tmp_dir"
fi

extension_dir=$tmp_dir/extension

mkdir $extension_dir
cd $extension_dir

log "🪄 Installing Shell Script Command Completion extension"

curl -s -L https://tetradresearch.gallery.vsassets.io/_apis/public/gallery/publisher/tetradresearch/extension//vscode-h2o/latest/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage -o extension.zip
unzip extension.zip > /dev/null 2>&1

if [ ! -f extension/out/cacheFetcher.js ]
then
logerror "❌ cacheFetcher.js is not present !"
exit 1
fi

if grep 'https://raw.githubusercontent.com/yamaton/h2o-curated-data/main/${kind}/json/${name}.json' extension/out/cacheFetcher.js
then
sed -i -E -e "s|https://raw.githubusercontent.com/yamaton/h2o-curated-data/main/\${kind}/json/\${name}.json|https://raw.githubusercontent.com/vdesabou/kafka-docker-playground/master/scripts/cli/playground.json|g" extension/out/cacheFetcher.js > /dev/null 2>&1
zip -r extension.zip extension > /dev/null 2>&1
mv extension.zip extension.vsix

set +e
code --uninstall-extension extension.vsix > /dev/null 2>&1

code --install-extension extension.vsix > /dev/null 2>&1
if [ $? -eq 0 ]
then
log "👏 extension is now installed"
else
logerror "❌ Failed to install Shell Script Command Completion extension"
fi
else
logerror "❌ cannot retrieve experimental url"
exit 1
fi
}

# :command.function
playground_run_command() {
# src/commands/run.sh
Expand Down Expand Up @@ -18474,6 +18426,55 @@ playground_tcp_proxy_toggle_writes_service_command() {
done
}

# :command.function
playground_tools_install_vscode_extension_command() {
# src/commands/tools/install-vscode-extension.sh
tmp_dir=$(mktemp -d -t pg-XXXXXXXXXX)
if [ -z "$PG_VERBOSE_MODE" ]
then
trap 'rm -rf $tmp_dir' EXIT
else
log "🐛📂 not deleting tmp dir $tmp_dir"
fi

extension_dir=$tmp_dir/extension

mkdir $extension_dir
cd $extension_dir

log "🪄 Installing Shell Script Command Completion extension"

curl -s -L https://tetradresearch.gallery.vsassets.io/_apis/public/gallery/publisher/tetradresearch/extension//vscode-h2o/latest/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage -o extension.zip
unzip extension.zip > /dev/null 2>&1

if [ ! -f extension/out/cacheFetcher.js ]
then
logerror "❌ cacheFetcher.js is not present !"
exit 1
fi

if grep 'https://raw.githubusercontent.com/yamaton/h2o-curated-data/main/${kind}/json/${name}.json' extension/out/cacheFetcher.js
then
sed -i -E -e "s|https://raw.githubusercontent.com/yamaton/h2o-curated-data/main/\${kind}/json/\${name}.json|https://raw.githubusercontent.com/vdesabou/kafka-docker-playground/master/scripts/cli/playground.json|g" extension/out/cacheFetcher.js > /dev/null 2>&1
zip -r extension.zip extension > /dev/null 2>&1
mv extension.zip extension.vsix

set +e
code --uninstall-extension extension.vsix > /dev/null 2>&1

code --install-extension extension.vsix > /dev/null 2>&1
if [ $? -eq 0 ]
then
log "👏 extension is now installed"
else
logerror "❌ Failed to install Shell Script Command Completion extension"
fi
else
logerror "❌ cannot retrieve experimental url"
exit 1
fi
}

# :command.function
playground_tools_read_avro_file_command() {
# src/commands/tools/read-avro-file.sh
Expand Down Expand Up @@ -24562,13 +24563,6 @@ parse_requirements() {
shift $#
;;

install-vscode-extension)
action="install-vscode-extension"
shift
playground_install_vscode_extension_parse_requirements "$@"
shift $#
;;

run)
action="run"
shift
Expand Down Expand Up @@ -26860,59 +26854,6 @@ playground_config_clipboard_parse_requirements() {

}

# :command.parse_requirements
playground_install_vscode_extension_parse_requirements() {
# :command.fixed_flags_filter
while [[ $# -gt 0 ]]; do
case "${1:-}" in
--help | -h)
long_usage=yes
playground_install_vscode_extension_usage
exit
;;

*)
break
;;

esac
done

# :command.dependencies_filter
if command -v code >/dev/null 2>&1; then
deps['code']="$(command -v code | head -n1)"
else
printf "missing dependency: code\n" >&2
printf "%s\n" "visit https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line to install" >&2
exit 1
fi

# :command.command_filter
action="install-vscode-extension"

# :command.parse_requirements_while
while [[ $# -gt 0 ]]; do
key="$1"
case "$key" in

-?*)
printf "invalid option: %s\n" "$key" >&2
exit 1
;;

*)
# :command.parse_requirements_case
# :command.parse_requirements_case_simple
printf "invalid argument: %s\n" "$key" >&2
exit 1

;;

esac
done

}

# :command.parse_requirements
playground_run_parse_requirements() {
# :command.fixed_flags_filter
Expand Down Expand Up @@ -30367,6 +30308,13 @@ playground_tools_parse_requirements() {
case $action in
-*) ;;

install-vscode-extension)
action="install-vscode-extension"
shift
playground_tools_install_vscode_extension_parse_requirements "$@"
shift $#
;;

read-avro-file)
action="read-avro-file"
shift
Expand Down Expand Up @@ -30417,6 +30365,59 @@ playground_tools_parse_requirements() {

}

# :command.parse_requirements
playground_tools_install_vscode_extension_parse_requirements() {
# :command.fixed_flags_filter
while [[ $# -gt 0 ]]; do
case "${1:-}" in
--help | -h)
long_usage=yes
playground_tools_install_vscode_extension_usage
exit
;;

*)
break
;;

esac
done

# :command.dependencies_filter
if command -v code >/dev/null 2>&1; then
deps['code']="$(command -v code | head -n1)"
else
printf "missing dependency: code\n" >&2
printf "%s\n" "visit https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line to install" >&2
exit 1
fi

# :command.command_filter
action="tools install-vscode-extension"

# :command.parse_requirements_while
while [[ $# -gt 0 ]]; do
key="$1"
case "$key" in

-?*)
printf "invalid option: %s\n" "$key" >&2
exit 1
;;

*)
# :command.parse_requirements_case
# :command.parse_requirements_case_simple
printf "invalid argument: %s\n" "$key" >&2
exit 1

;;

esac
done

}

# :command.parse_requirements
playground_tools_read_avro_file_parse_requirements() {
# :command.fixed_flags_filter
Expand Down Expand Up @@ -36390,7 +36391,6 @@ run() {
"config editor") playground_config_editor_command ;;
"config folder_zip_or_jar") playground_config_folder_zip_or_jar_command ;;
"config clipboard") playground_config_clipboard_command ;;
"install-vscode-extension") playground_install_vscode_extension_command ;;
"run") playground_run_command ;;
"re-run") playground_re_run_command ;;
"history") playground_history_command ;;
Expand Down Expand Up @@ -36429,6 +36429,7 @@ run() {
"tcp-proxy toggle-writes-client") playground_tcp_proxy_toggle_writes_client_command ;;
"tcp-proxy toggle-writes-service") playground_tcp_proxy_toggle_writes_service_command ;;
"tools") playground_tools_command ;;
"tools install-vscode-extension") playground_tools_install_vscode_extension_command ;;
"tools read-avro-file") playground_tools_read_avro_file_command ;;
"tools read-parquet-file") playground_tools_read_parquet_file_command ;;
"debug") playground_debug_command ;;
Expand Down
Loading

0 comments on commit 6d501b4

Please sign in to comment.