diff --git a/main.go b/main.go index eff7c25..8f47f2d 100644 --- a/main.go +++ b/main.go @@ -2,23 +2,32 @@ package main import ( "bufio" + "errors" "flag" "fmt" - "gitea.hbanafa.com/hesham/mystc-api/pkg/endpoints" - "gitea.hbanafa.com/hesham/mystc-api/pkg/models" "os" "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 PATH_PHONES_LIST = "/api/mystc-api-authentication/phones-list" +var ErrMissingFlags = errors.New("flag: missing required flags. use -h") + func main() { id := flag.String("id", "", "National ID or Iqama") pw := flag.String("password", "", "MySTC Password") flag.Parse() + if *id == "" || *pw == "" { + fmt.Fprintf(os.Stderr, "%s\n", ErrMissingFlags.Error()) + os.Exit(1) + } + phones, err := endpoints.GetPhonesList(*id, *pw) if err != nil { fmt.Println(err.Error())