Skip to content

Commit

Permalink
integrate new version of cli pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
kazhuravlev committed Feb 20, 2024
1 parent 65fd516 commit 6916a6c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions cmd/gt/helpers.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package main

import (
"context"
"errors"
"fmt"

repomanager "github.com/kazhuravlev/git-tools/internal/repo-manager"
"github.com/urfave/cli/v3"
)

func withManager(action func(c *cli.Context, manager *repomanager.Manager) error) cli.ActionFunc {
return func(c *cli.Context) error {
func withManager(action func(context.Context, *cli.Command, *repomanager.Manager) error) cli.ActionFunc {
return func(ctx context.Context, c *cli.Command) error {
repoPath := c.String(flagRepoPath)
if repoPath == "" {
return errors.New("path to repo must be set by flag " + flagRepoPath)
Expand All @@ -20,6 +21,6 @@ func withManager(action func(c *cli.Context, manager *repomanager.Manager) error
return fmt.Errorf("cannot build repo manager: %w", err)
}

return action(c, manager)
return action(ctx, c, manager)
}
}
8 changes: 4 additions & 4 deletions cmd/gt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ func main() {
}
}

func buildTagIncrementor(component repomanager.Component) func(*cli.Context, *repomanager.Manager) error {
return func(c *cli.Context, m *repomanager.Manager) error {
func buildTagIncrementor(component repomanager.Component) func(context.Context, *cli.Command, *repomanager.Manager) error {
return func(ctx context.Context, c *cli.Command, m *repomanager.Manager) error {
repoPath := c.String(flagRepoPath)
if repoPath == "" {
return errors.New("path to repo must be set by flag " + flagRepoPath)
Expand All @@ -112,7 +112,7 @@ func buildTagIncrementor(component repomanager.Component) func(*cli.Context, *re
}
}

func cmdTagGetSemverLast(c *cli.Context, m *repomanager.Manager) error {
func cmdTagGetSemverLast(ctx context.Context, c *cli.Command, m *repomanager.Manager) error {
maxTag, err := m.GetTagsSemverMax()
if err != nil {
return fmt.Errorf("cannot get max tag: %w", err)
Expand All @@ -122,7 +122,7 @@ func cmdTagGetSemverLast(c *cli.Context, m *repomanager.Manager) error {
return nil
}

func cmdLint(c *cli.Context, m *repomanager.Manager) error {
func cmdLint(ctx context.Context, c *cli.Command, m *repomanager.Manager) error {
tags, err := m.GetTagsSemverTopN(100)
if err != nil {
return fmt.Errorf("cannot last semver tags: %w", err)
Expand Down

0 comments on commit 6916a6c

Please sign in to comment.