Skip to content

Commit

Permalink
add better error messages and debugging output
Browse files Browse the repository at this point in the history
  • Loading branch information
rndmh3ro committed Nov 1, 2023
1 parent d16d390 commit 86497d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions conf/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ func ReadConf() {

func ParseCliOpts() {
var versionFlag bool
var debugFlag bool
pflag.BoolVar(&versionFlag, "version", false, "Print the version of the program")
pflag.BoolVar(&debugFlag, "debug", false, "enable debug outpuz")

pflag.StringP("confluence_url", "u", "https://confluence.example.com/rest/api", "The URL to the Confluence REST-API with http(s)")
pflag.StringP("confluence_token", "t", "", "The token to authenticate against the Confluence REST-API")
Expand Down
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ func main() {

domain := getDomainName(cURL)

goconfluence.SetDebug(viper.GetViper().GetBool("debug"))

api, err := goconfluence.NewAPI(cURL, "", cToken)
if err != nil {
log.Fatal(err)
log.Fatal("Error connecting to Confluence: ", err)
}

childPages, err := api.GetChildPages(cPageID)
if err != nil {
log.Fatal(err)
log.Fatal("Error getting child pages: ", err)
}

now := time.Now()
Expand All @@ -57,7 +59,7 @@ func main() {
for _, v := range childPages.Results {
hist, err := api.GetHistory(v.ID)
if err != nil {
log.Fatal(err)
log.Fatal("Error getting history: ", err)
}
lastUpdateTimeString := hist.LastUpdated.When
lastUpdateTime, err := time.Parse("2006-01-02T15:04:05.000Z", lastUpdateTimeString)
Expand Down

0 comments on commit 86497d8

Please sign in to comment.