From 4bf4f0252c1d1f782432cc9e5d81336690f4a320 Mon Sep 17 00:00:00 2001 From: JesusPerez Date: Tue, 31 Aug 2021 16:48:26 +0100 Subject: [PATCH] chore: add version option to arguments and documented --- README.md | 31 ++++++++++++++++++++++++++++++- main.go | 7 +++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b61755d..e509203 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,25 @@ So this is what it use and his focus, but *{...}* define what it is, a group of Short version, can be interpreted as: > whatever group **{...}** of **UpCloud** resources managed via UpCloud **API** + +## Download Release binary + +1 - Copy attachment url from [releases page](https://rlung.librecloud.online/LibreCloud/Upclapi/releases) + +2 - Use this **shell** command changing attachment URL: + +```bash +curl -sLS "** attachment URL **" | gunzip > upclapi ; chmod +x upclapi +```` + +3 - Test it by running in **shell**: + +```bash +./upclapi -h +``` + +4 - Move this file to something like: /usr/local/bin or wherever you like. + ## Build from source - Clone this repository and go to folder: @@ -100,11 +119,20 @@ As a more secure option it is possible to encrypt sensitive informations like: - Credentials (username/password) - Data config file in yaml +- Version + +```bash +# Getting version +upclapi version +# or upclapi -v +``` + - Help ```bash # Getting help -go run ./... --help +upclapi --help +# or upclapi -h ``` ```txt @@ -132,6 +160,7 @@ Usage of upclapi: ssh id for ssh commands (or defaul id_rsa) -t string target item for command + -v version ``` - Create Server diff --git a/main.go b/main.go index 2129cdc..1696828 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,7 @@ import ( // https://abhinavg.net/posts/flexible-yaml/ ) +const VERSION = "0.1.1" const SEPARATOR = "::" const DATA_CFG = "datacfg.yaml" const DFLT_COMMAND= "infoserver" @@ -46,6 +47,7 @@ type RunFlags struct { out string target string sid string + version bool } type CoderConfig struct { cmd string @@ -445,6 +447,10 @@ func init() { } func main() { + if os.Args[1] == "-v" || os.Args[1] == "version" { + fmt.Fprintf(os.Stdout, "{...} UpClapi version:%s\n",VERSION) + os.Exit(0) + } if len(os.Args) > 1 || len(os.Getenv("UPCLAPI_COMMAND")) > 0 { os.Exit(run()) } else { @@ -528,6 +534,7 @@ func ParseFlags() (RunFlags,error) { flag.StringVar(&runFlags.out, "o", runFlags.out, "output format (attached for infofloatip)") flag.StringVar(&runFlags.target, "t", runFlags.target, "target item for command ") flag.StringVar(&runFlags.sid, "sid", runFlags.sid, "ssh id for ssh commands (or defaul id_rsa)") + flag.BoolVar(&runFlags.version,"v",false,"version") // Actually parse the flags flag.Parse()