This is an automated email from the ASF dual-hosted git repository. msciabarra pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/openserverless-cli.git
commit 8cc738c8ab9ab56a33359372ccbf02c79aa59707 Author: Michele Sciabarra <[email protected]> AuthorDate: Mon Aug 5 17:07:44 2024 +0200 add: install.sh and install.ps1 for an automated installer of ops --- README.md | 29 +++++++++++++++++++---------- install.ps1 | 1 + install.sh | 40 ++++++++++++++++++++++++++++++++++++++++ main.go | 4 ++-- 4 files changed, 62 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2ed1c2d..045c155 100644 --- a/README.md +++ b/README.md @@ -18,23 +18,32 @@ ~ --> -**WARNING: this is still work in progress** +# `ops`, the Apache OpenServerless all-mighty CLI tool. -The code may not build, there can be errors, and it can even destroy your hard disk or send you in another dimension. +Quick install in Linux, MacOSX and Windows with WSL or GitBash: -Documentation is also work in progress.... +``` +curl -sL bit.ly/get-ops | bash +```` + +To be implemented: quick install in Windows with PowerShell + +``` +irm bit.ly/get-ops-exe | iex +```` -# `ops`, the OpenServerless all-mighty CLI tool. +# What is ops? -Ops is a task executor on steroids. +Ops is the OpenServerless CLI. +It is a task executor on steroids. -- it embeds [`Task`](https://taskfile.dev)) +- it embeds [`task`](https://taskfile.dev)) - it embeds [`wsk`](https://github.com/apache/openwhisk-cli) -- it embeds many other utility commands (check with `ops -help`) -- automatically download other commad line tools he neeeds as prerequisites -- automatically download a predefined set of tasks downloaded from github -- taskfiles are organized in commands and subcommands, hiearachally +- it embeds a lot of other utility commands (check with `ops -help`) +- automatically download and updated commad line tools he neeeds as prerequisites +- automatically download and updated a predefined set of tasks from github +- taskfiles are organized in commands and subcommands, hiearachally - taskfiles have options powered by [docopt](http://docopt.org/) - it supports plugins diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..c38058a --- /dev/null +++ b/install.ps1 @@ -0,0 +1 @@ +echo "Sorry this is just placeholder - TODO" \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..ca1d245 --- /dev/null +++ b/install.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +OS="$(uname -s)" +ARCH="$(uname -m)" + +case "$OS-$ARCH" in +(Linux-x86-64) SUFFIX="_linux_amd64" ; EXT=".tar.gz" ;; +(Linux-arm64) SUFFIX="_linux_arm64" ; EXT=".tar.gz";; +(Darwin-x86_64) SUFFIX="_darwin_amd64" ; EXT=".tar.gz" ;; +(Darwin-arm64) SUFFIX="_darwin_arm64" ; EXT=".tar.gz" ;; +(MINGW64_NT-*) SUFFIX="_windows_amd64" ; EXT=".zip" ;; +(*) echo "unknown system"; exit 1 ;; +esac + +OPSROOT="https://raw.githubusercontent.com/apache/openserverless-task/main/opsroot.json" +VERSION="$(curl -sL $OPSROOT | sed -n 's/^.*"version": "\([^"]*\)",/\1/p')" +FILE="openserverless-cli_${VERSION}$SUFFIX$EXT" +URL="https://github.com/apache/openserverless-cli/releases/download/v$VERSION/$FILE" +mkdir -p ~/.local/bin +curl -sL "$URL" -o "/tmp/$FILE" + +if test "$EXT" == ".zip" +then unzip "$FILE" ops.exe -d "~/.local/bin" +else tar xzvf "$FILE" ops -C "~/.local/bin" +fi + +if ! test -e ~/.local/bin/ops* +then echo "cannot install ops - download and unpack it in a folder in the path from here:" + echo "$URL" + exit 1 +fi + +if ! which ops +then + echo "$HOME/.local/bin is not in the path - adding it" + echo 'export PATH=~/.local/bin:"$PATH"' >>~/.bashrc + echo 'export PATH=~/.local/bin:"$PATH"' >>~/.zshrc + echo please restart your terminal to find ops in your path +fi +exit 0 \ No newline at end of file diff --git a/main.go b/main.go index d198667..7234d2c 100644 --- a/main.go +++ b/main.go @@ -108,7 +108,7 @@ func info() { // not available in taskfiles var mainTools = []string{ - "task", "version", "info", "help", "serve", "update", "retry", "login", "config", "plugin", + "task", "version", "info", "help", "serve", "update", "retry", "login", "config", "plugin", "reset", } func executeMainToolsAndExit(cmd string, args []string, opsHome string) int { @@ -165,7 +165,7 @@ func executeMainToolsAndExit(cmd string, args []string, opsHome string) int { if !info.IsDir() { log.Fatal("cannot reset, not a directory", home) } - if !confirm(fmt.Sprintf("I am going to remove the subfolder %s, are you sure", home)) { + if !confirm(fmt.Sprintf("I am going to remove the subfolder %s, are you sure :", home)) { log.Fatal("reset aborted") } err = os.RemoveAll(home)
