main: quite if missing parameters
Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
41a6f0a1e1
commit
485ae194e5
13
main.go
13
main.go
@ -2,23 +2,32 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gitea.hbanafa.com/hesham/mystc-api/pkg/endpoints"
|
|
||||||
"gitea.hbanafa.com/hesham/mystc-api/pkg/models"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"gitea.hbanafa.com/hesham/mystc-api/pkg/endpoints"
|
||||||
|
"gitea.hbanafa.com/hesham/mystc-api/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
const URL_MYSTC_API_BASE = "https://mystc.stc.com.sa"
|
const URL_MYSTC_API_BASE = "https://mystc.stc.com.sa"
|
||||||
const PATH_PHONES_LIST = "/api/mystc-api-authentication/phones-list"
|
const PATH_PHONES_LIST = "/api/mystc-api-authentication/phones-list"
|
||||||
|
|
||||||
|
var ErrMissingFlags = errors.New("flag: missing required flags. use -h")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
id := flag.String("id", "", "National ID or Iqama")
|
id := flag.String("id", "", "National ID or Iqama")
|
||||||
pw := flag.String("password", "", "MySTC Password")
|
pw := flag.String("password", "", "MySTC Password")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *id == "" || *pw == "" {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s\n", ErrMissingFlags.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
phones, err := endpoints.GetPhonesList(*id, *pw)
|
phones, err := endpoints.GetPhonesList(*id, *pw)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Println(err.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user