Skip to content

Commit

Permalink
Merge branch 'release/v24.04.119'
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasarvelo committed Apr 28, 2024
2 parents f9880a1 + 7e61b2e commit 8827e28
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 30 deletions.
Binary file added .github/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 55 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,71 @@
RestTail
--------

RestTail is a Go client library for interacting with the [TestRail](http://www.gurock.com/testrail/) API
![RestTail Logo](https://raw.githubusercontent.com/nicholasarvelo/resttail-sdk/main/.github/logo.png)

RestTail is an SDK written in Go for interacting with the [TestRail's API](http://www.gurock.com/testrail/)


Example usage
-------------

```go
package main
package main

import (
"flag"
"fmt"
"log"
"os"
"strings"

"github.com/nicholasarvelo/resttail"
)

import "github.com/nicholasarvelo/RestTail"
func main() {
var projectNameList string
setupFlags(&projectNameList)

func main(){
flag.Parse()

url := flag.String(
"testrail-url",
"",
"(Required) TrailRail Account URL",
)
if err := validateFlags(); err != nil {
fmt.Println(err)
flag.Usage()
os.Exit(1)
}

username := flag.String(
"testrail-username",
"",
"(Required) The TestRail username",
)
projectNames := strings.Split(projectNameList, ",")
if len(projectNames) == 0 || projectNames[0] == "" {
fmt.Println("Error: no project names provided")
flag.Usage()
os.Exit(1)
}

password := flag.String(
"testrail-password",
"",
"(Required) The TestRail password",
)
apiClient := resttail.NewClient(*url, *username, *password)
activeProjects, err := apiClient.GetProjects(false)
if err != nil {
log.Fatal(err)
}

flag.Parse()
fmt.Printf("Project Name: %s\nProject ID: %d\n Project URL: %s\n",
activeProjects.Projects[0].Name,
activeProjects.Projects[0].ID,
activeProjects.Projects[0].URL,
)
}

if *username == "" || *password == "" {
flag.Usage()
os.Exit(1)
}
func setupFlags(projectNameList *string) {
flag.StringVar(projectNameList, "project-names", "", "A comma separated list of project names")
flag.StringVar(url, "testrail-url", "", "The TestRail Account URL")
flag.StringVar(username, "testrail-username", "", "The TestRail username")
flag.StringVar(password, "testrail-password", "", "The TestRail password")
}

apiClient := resttail.NewClient(*url, *username, *password)
}
func validateFlags() error {
if *username == "" || *password == "" || *url == "" {
return fmt.Errorf("missing required flags: username, password, or url")
}
if !strings.HasPrefix(*url, "https://") {
*url = "https://" + *url
}
return nil
}
```
2 changes: 1 addition & 1 deletion custom_types.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package resttail
// DO NOT MODIFY THIS CODE!!
// This code is autogenerated from an API query.
// To regenerate:
// go install -v ./... && resttail-generate
// go install -v ./... && resttail-sdk-generate

// Custom status values

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/nicholasarvelo/resttail"
"github.com/nicholasarvelo/resttail-sdk"
"os"
)

Expand Down

0 comments on commit 8827e28

Please sign in to comment.