From d11fc9bfcd0ac8da7df1b6d536e326615b037b36 Mon Sep 17 00:00:00 2001 From: samueljmello <6161359+samueljmello@users.noreply.github.com> Date: Mon, 24 Jul 2023 22:07:26 -0400 Subject: [PATCH] clean up & reduce code --- README.md | 6 ++++-- main.go | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2cf9c66..05cf3c9 100644 --- a/README.md +++ b/README.md @@ -53,13 +53,15 @@ Usage: gh pma [flags] Flags: - --confirm Auto respond to confirmation prompt + --confirm Auto respond to visibility alignment confirmation prompt + -c, --create-csv Whether to create a CSV file with the results. + -i, --create-issues Whether to create issues in target org repositories or not. --ghes-api-url string Required if migrating from GHES. The domain name for your GHES instance. For example: ghes.contoso.com (default "github.com") --github-source-org string Uses GH_SOURCE_PAT env variable or --github-source-pat option. Will fall back to GH_PAT or --github-target-pat if not set. --github-source-pat string --github-target-org string Uses GH_PAT env variable or --github-target-pat option. --github-target-pat string -h, --help help for gh - -t, --threads int Number of threads to process concurrently. Maximum of 10 allowed. Increasing this number could get your PAT blocked due to API limiting. (default 3) + --threads int Number of threads to process concurrently. Maximum of 10 allowed. Increasing this number could get your PAT blocked due to API limiting. (default 3) -v, --version version for gh ``` \ No newline at end of file diff --git a/main.go b/main.go index eb052d3..cd1789c 100644 --- a/main.go +++ b/main.go @@ -330,6 +330,14 @@ func Debug(message string) string { return message } +func DisplayRateLeft() { + // validate we have API attempts left + rateLeft, _ := ValidateApiRate(SourceRestClient, "core") + rateMessage := Cyan("API Rate Limit Left:") + OutputNotice(fmt.Sprintf("%s %d", rateMessage, rateLeft)) + LF() +} + func IsTargetProvided() bool { if GithubTargetOrg != "" { return true @@ -688,6 +696,7 @@ func Process(cmd *cobra.Command, args []string) (err error) { LF() OutputWarning("Alignment process abandoned.") LF() + DisplayRateLeft() return err } @@ -702,20 +711,18 @@ func Process(cmd *cobra.Command, args []string) (err error) { // on successful processing if err == nil { + LF() OutputNotice( fmt.Sprintf( "Successfully processed %d repositories.", len(ToProcessRepositories), ), ) + LF() } } - // validate we have API attempts left - rateLeft, _ := ValidateApiRate(SourceRestClient, "core") - rateMessage := Cyan("API Rate Limit Left:") - OutputNotice(fmt.Sprintf("%s %d", rateMessage, rateLeft)) - LF() + DisplayRateLeft() // always return return err