Extends arkanum command and option structure (#62)
ci/woodpecker/push/test Pipeline was successful Details
ci/woodpecker/push/next Pipeline was successful Details
ci/woodpecker/push/deploy Pipeline was successful Details

#### 📖 Summary

- adds nested arguments for arkanum:

```
arkanum <flag> COMMAND OPTION <ARGUMENT>
```

#### 📑 Test Plan

> 💡 Select your test plan for the code changes.

| Choice | Test Method       |
| :----: | :-----------      |
|      | CI pipeline tests |
|        | Custom test       |
|        | No test plan      |

##### Details / Justification

<!-- Add your test details or justification for missing tests here. -->

#### 📚 Additional Notes

- fixes #61

Co-authored-by: OCram85 <marco.blessing@googlemail.com>
Reviewed-on: CodeServer/arkanum#62
This commit is contained in:
OCram85 2023-08-03 09:51:02 +02:00
parent 26754e83f9
commit e700e7b477
4 changed files with 159 additions and 67 deletions

View File

@ -40,7 +40,7 @@ RUN \
chmod +x /etc/bash_completion.d/arkanum-completion && \ chmod +x /etc/bash_completion.d/arkanum-completion && \
echo 'source /etc/bash_completion.d/arkanum-completion' >> /etc/bash.bashrc && \ echo 'source /etc/bash_completion.d/arkanum-completion' >> /etc/bash.bashrc && \
touch "$HOME/enable_motd" && \ touch "$HOME/enable_motd" && \
echo "if [[ ! -e \"$HOME/data/User/settings.json\" ]]; then arkanum --install-extensions && arkanum --reset-codesetting && \ echo "if [[ ! -e \"$HOME/data/User/settings.json\" ]]; then arkanum config install-extensions && arkanum config reset-codesettings && \
echo -e \"🧙 \\e[32markanum\\e[0m: Please reload Arkanum to finalize the setup...\" && read foo; fi" >> /etc/bash.bashrc && \ echo -e \"🧙 \\e[32markanum\\e[0m: Please reload Arkanum to finalize the setup...\" && read foo; fi" >> /etc/bash.bashrc && \
echo "if [[ -e \"$HOME/enable_motd\" ]]; then echo -e \"Use 🧙 \\e[32m'arkanum'\\e[0m to install missing runtimes like dotnet or NodeJs.\"; fi" >> /etc/bash.bashrc echo "if [[ -e \"$HOME/enable_motd\" ]]; then echo -e \"Use 🧙 \\e[32m'arkanum'\\e[0m to install missing runtimes like dotnet or NodeJs.\"; fi" >> /etc/bash.bashrc

View File

@ -170,26 +170,39 @@ Added `arkanum` to help installing common runtimes in container.
This helps reducing the image size. This helps reducing the image size.
``` ```
🧙 arkanum ✨🌌☄️💥 is used to install optional runtimes for developing in a 🧙 arkanum ✨🌌☄️💥 is used to install optional tools for developing in a
code-server container environment. code-server container environment.
Syntax: arkanum RUNTIME ... Syntax: arkanum <flags> COMMAND OPTION ARGUMENT
RUNTIME [docker-cli|dotnet|gitea|golang|nodejs|volta|powershell] COMMAND
docker-cli Installs the latest docker-ce cli. config The config command is used to modify arkanum itself.
dotnet Installs latest LTS dotnet core sdk + runtime. git The git command is a wrapper for git helpers.
gitea Installs gitea tools like the changelog generator. install The install command is used to add different tools
golang Installs golang 1.19.3. help Shows this help text.
nodejs Installs latest NodeJs LTS version using Volta.
volta Installs Volta as NodeJs version manager.
powershell Installs latest PowerShell LTS version.
--disable-motd Disables hint in new bash terminal.
--install-extensions Installs predefined recommended extensions.
--reset-codesetting Sets VS Code user setting with basic (Fira Code).
-h Prints this help message.
Example 1: arkanum dotnet OPTION
Example 2: arkanum golang nodejs config:
Example 3: arkanum --disable-motd disable-motd Disables hint in new bash terminal.
install extensions Installs predefined recommended extensions.
reset-codesettings Sets VS Code user setting with basic (Fira Code).
git:
setup Takes two arguments to setup the git client:
1) Username
2) Email address
install:
docker-cli Installs the latest docker-cli.
dotnet Installs latest LTS dotnet core sdk + runtime.
gitea Installs gitea tools like the changelog generator.
golang Installs golang 1.19.3.
nodejs Installs latest NodeJs LTS version using Volta.
volta Installs Volta as NodeJS version manager.
powershell Installs latest PowerShell LTS version.
Example 1: arkanum git setup "my-name" "my-email"
Example 2: arkanum install golang
Example 3: arkanum config disable-motd
``` ```
### 📝 Fira Code (NerdFont patched) ### 📝 Fira Code (NerdFont patched)

137
arkanum
View File

@ -4,26 +4,39 @@ set -e
function showHelp() { function showHelp() {
cat << HELP cat << HELP
🧙 arkanum ✨🌌☄️💥 is used to install optional runtimes for developing in a 🧙 arkanum ✨🌌☄️💥 is used to install optional tools for developing in a
code-server container environment. code-server container environment.
Syntax: arkanum RUNTIME ... Syntax: arkanum <flags> COMMAND OPTION ARGUMENT
RUNTIME [docker-cli|dotnet|gitea|golang|nodejs|volta|powershell] COMMAND
docker-cli Installs the latest docker-cli. config The config command is used to modify arkanum itself.
dotnet Installs latest LTS dotnet core sdk + runtime. git The git command is a wrapper for git helpers.
gitea Installs gitea tools like the changelog generator. install The install command is used to add different tools
golang Installs golang 1.19.3. help Shows this help text.
nodejs Installs latest NodeJs LTS version using Volta.
volta Installs Volta as NodeJS version manager.
powershell Installs latest PowerShell LTS version.
--disable-motd Disables hint in new bash terminal.
--install-extensions Installs predefined recommended extensions.
--reset-codesetting Sets VS Code user setting with basic (Fira Code).
-h Prints this help message.
Example 1: arkanum dotnet OPTION
Example 2: arkanum golang nodejs config:
Example 3: arkanum --disable-motd disable-motd Disables hint in new bash terminal.
install extensions Installs predefined recommended extensions.
reset-codesettings Sets VS Code user setting with basic (Fira Code).
git:
setup Takes two arguments to setup the git client:
1) Username
2) Email address
install:
docker-cli Installs the latest docker-cli.
dotnet Installs latest LTS dotnet core sdk + runtime.
gitea Installs gitea tools like the changelog generator.
golang Installs golang 1.19.3.
nodejs Installs latest NodeJs LTS version using Volta.
volta Installs Volta as NodeJS version manager.
powershell Installs latest PowerShell LTS version.
Example 1: arkanum git setup "my-name" "my-email"
Example 2: arkanum install golang
Example 3: arkanum config disable-motd
HELP HELP
} }
@ -31,6 +44,8 @@ function disableMotd() {
if [[ -e "$HOME/enable_motd" ]]; then if [[ -e "$HOME/enable_motd" ]]; then
say "Disabling 'arkanum' motd..." "disableMotd" say "Disabling 'arkanum' motd..." "disableMotd"
rm -f "$HOME/enable_motd" rm -f "$HOME/enable_motd"
else
sayW "Arkanum Motd already disabled" "disableMotd"
fi fi
} }
@ -244,51 +259,79 @@ EOF
say "done." "VSCode" say "done." "VSCode"
} }
function setGitConfig() {
if [[ "$#" != "2" ]]; then
sayE "Invalid arguments given. Please provide '<user>' and 'email'!" "Git"
exit 1
fi
say "Setting global git config..." "Git"
git config --global user.name "$1"
git config --global user.email "$2"
say "Returning global config:" "Git"
git config --list --global
}
function main() { function main() {
if [[ "$#" == "0" ]]; then if [[ "$#" == "0" ]]; then
showHelp showHelp
exit 0 exit 0
fi fi
for i in "$@"; do # Command filter
if [[ "$1" == "-h" ]]; then if [[ "$1" =~ ^help|-h|--h$ ]]; then
showHelp showHelp
exit 0 exit 0
elif [[ "$i" == "docker-cli" ]]; then fi
instDockerCLI
elif [[ "$i" == "dotnet" ]]; then # CONFIG command
instDotNet if [[ "$1" == "config" ]]; then
elif [[ "$i" == "golang" ]]; then # disable-motd option
instGoLang "$2" if [[ "$2" == "disable-motd" ]]; then
elif [[ "$i" == "nodejs" ]]; then
if [[ "$2" == "--legacy" ]]; then
sayW "Installing NodeJS with legacy function" "Arkanum"
instNodeJs
else
instVolta
instNodeJS2
fi
elif [[ "$i" == "volta" ]]; then
instVolta
elif [[ "$i" == "powershell" ]]; then
instPwsh
elif [[ "$i" == "gitea" ]]; then
instGiteaTools
elif [[ "$i" == "--disable-motd" ]]; then
disableMotd disableMotd
exit 0 exit 0
elif [[ "$i" == "--install-extensions" ]]; then # install-extensions option
elif [[ "$2" == "install-extensions" ]]; then
instCodeExtension instCodeExtension
exit 0 exit 0
elif [[ "$i" == "--reset-codesetting" ]]; then # reset-codesetting option
elif [[ "$2" == "reset-codesettings" ]]; then
setCodeSettings setCodeSettings
exit 0 exit 0
else else
sayE "Unknown parameter value given!($i)." sayE "Unknown option ($2) given for command 'config'!"
fi
# GIT command
elif [[ "$1" == "git" ]]; then
# setup option
if [[ "$2" == "setup" ]]; then
setGitConfig "$3" "$4"
else
sayE "Unknown option ($2) given for command 'git'!"
fi
# INSTALL command
elif [[ "$1" == "install" ]]; then
# docker-cli option
if [[ "$2" == "docker-cli" ]]; then
instDockerCLI
elif [[ "$2" == "dotnet" ]]; then
instDotNet
elif [[ "$2" == "golang" ]]; then
instGoLang "$3"
elif [[ "$2" == "nodejs" ]]; then
instVolta
instNodeJs
elif [[ "$2" == "volta" ]]; then
instVolta
elif [[ "$2" == "powershell" ]]; then
instPwsh
elif [[ "$2" == "gitea" ]]; then
instGiteaTools
fi
else
sayE "Unknown parameter value given!($1)."
showHelp showHelp
exit 1 exit 1
fi fi
done
} }
main "$@" main "$@"

View File

@ -1,3 +1,39 @@
#!/bin/bash #!/bin/env bash
complete -W "--disable-motd --install-extensions --reset-codesetting docker-cli dotnet gitea golang nodejs volta powershell -h" arkanum #complete -W "--disable-motd --install-extensions --reset-codesetting docker-cli dotnet gitea golang nodejs volta powershell -h" arkanum
function _command_completions() {
local cur prev
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case ${COMP_CWORD} in
1)
# shellcheck disable=2207,SC2086
COMPREPLY=($(compgen -W "config git install help" -- ${cur}))
;;
2)
case ${prev} in
config)
# shellcheck disable=2207,SC2086
COMPREPLY=($(compgen -W "disable-motd install-extensions reset-codesettings" -- ${cur}))
;;
git)
# shellcheck disable=2207,SC2086
COMPREPLY=($(compgen -W "setup" -- ${cur}))
;;
install)
# shellcheck disable=2207,SC2086
COMPREPLY=($(compgen -W "docker-cli dotnet golang nodejs volta powershell gitea" -- ${cur}))
;;
help)
;;
esac
;;
*)
COMPREPLY=()
;;
esac
}
complete -F _command_completions arkanum