chore: add version option to arguments and documented
This commit is contained in:
parent
7691f6c316
commit
4bf4f0252c
31
README.md
31
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 <u>attachment URL</u>:
|
||||
|
||||
```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
|
||||
|
7
main.go
7
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()
|
||||
|
Loading…
Reference in New Issue
Block a user