Skip to content

Commit

Permalink
optimized imports
Browse files Browse the repository at this point in the history
  • Loading branch information
hedzr committed Mar 30, 2024
1 parent 7f511dd commit 3bacf6a
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 27 deletions.
3 changes: 2 additions & 1 deletion cli/atoa/r1.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"regexp"
"strings"

"github.com/hedzr/cmdr/v2/pkg/exec"
"github.com/hedzr/evendeep/ref"
logz "github.com/hedzr/logg/slog"

"github.com/hedzr/cmdr/v2/pkg/exec"
)

//
Expand Down
3 changes: 2 additions & 1 deletion cli/baseopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (

"gopkg.in/hedzr/errors.v3"

"github.com/hedzr/cmdr/v2/conf"
"github.com/hedzr/is/term/color"
"github.com/hedzr/store"

"github.com/hedzr/cmdr/v2/conf"
)

func (c *BaseOpt) errIsSignalFallback(err error) bool {
Expand Down
4 changes: 3 additions & 1 deletion cli/for_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"io"
"time"

"github.com/hedzr/cmdr/v2/conf"
"github.com/hedzr/store"

"github.com/hedzr/cmdr/v2/conf"
)

func rootCmdForTesting() (root *RootCommand) { //nolint:funlen,revive //for test
Expand Down Expand Up @@ -1061,6 +1062,7 @@ func (s *appS) Name() string { return s.root.AppName }
func (s *appS) Version() string { return s.root.Version }
func (s *appS) Worker() Runner { return s.Runner }
func (s *appS) Root() *RootCommand { return s.root }
func (s *appS) Args() []string { return s.args }

func (s *appS) ensureNewApp() App { //nolint:unparam
if s.root == nil {
Expand Down
3 changes: 2 additions & 1 deletion cli/worker/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"fmt"
"runtime"

"github.com/hedzr/cmdr/v2/cli"
"github.com/hedzr/is/states"
logz "github.com/hedzr/logg/slog"

"github.com/hedzr/cmdr/v2/cli"
)

func (w *workerS) addBuiltinCommands(root *cli.RootCommand) (err error) { //nolint:unparam //unified form
Expand Down
3 changes: 2 additions & 1 deletion cli/worker/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (

errorsv3 "gopkg.in/hedzr/errors.v3"

"github.com/hedzr/cmdr/v2/cli"
logz "github.com/hedzr/logg/slog"

"github.com/hedzr/cmdr/v2/cli"
)

func (w *workerS) exec(ctx *parseCtx) (err error) {
Expand Down
3 changes: 2 additions & 1 deletion cli/worker/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (

errorsv3 "gopkg.in/hedzr/errors.v3"

"github.com/hedzr/cmdr/v2/cli"
logz "github.com/hedzr/logg/slog"

"github.com/hedzr/cmdr/v2/cli"
)

func (w *workerS) parse(ctx *parseCtx) (err error) { //nolint:revive
Expand Down
17 changes: 10 additions & 7 deletions cli/worker/pre_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (

errorsv3 "gopkg.in/hedzr/errors.v3"

"github.com/hedzr/store"

"github.com/hedzr/cmdr/v2/cli"
"github.com/hedzr/cmdr/v2/loaders"
"github.com/hedzr/store"
)

func TestWorkerS_Pre(t *testing.T) {
Expand All @@ -27,14 +28,16 @@ func TestWorkerS_Pre(t *testing.T) {

ww.setArgs([]string{"--debug"})
ww.Config.Store = store.New()
ww.Loaders = []cli.Loader{loaders.NewConfigFileLoader(), loaders.NewEnvVarLoader()}
// ww.Loaders = []cli.Loader{loaders.NewConfigFileLoader(), loaders.NewEnvVarLoader()}
_ = app

err := ww.Run(withTasksBeforeParse(func(root *cli.RootCommand, runner cli.Runner) (err error) { //nolint:revive
root.SelfAssert()
t.Logf("root.SelfAssert() passed.")
return
}))
err := ww.Run(
withTasksBeforeParse(func(root *cli.RootCommand, runner cli.Runner) (err error) { //nolint:revive
root.SelfAssert()
t.Logf("root.SelfAssert() passed.")
return
}),
)
if err != nil {
t.Fatal(err)
}
Expand Down
5 changes: 3 additions & 2 deletions cli/worker/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import (
"strconv"
"strings"

"github.com/hedzr/cmdr/v2/cli"
"github.com/hedzr/cmdr/v2/pkg/exec"
"github.com/hedzr/is/states"
"github.com/hedzr/is/term"
"github.com/hedzr/is/term/color"
logz "github.com/hedzr/logg/slog"

"github.com/hedzr/cmdr/v2/cli"
"github.com/hedzr/cmdr/v2/pkg/exec"
)

type discardP struct{}
Expand Down
3 changes: 2 additions & 1 deletion cli/worker/shows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package worker
import (
"gopkg.in/hedzr/errors.v3"

logz "github.com/hedzr/logg/slog"

"github.com/hedzr/cmdr/v2/cli"
"github.com/hedzr/cmdr/v2/internal/hs"
logz "github.com/hedzr/logg/slog"
)

func (w *workerS) showVersion(ctx *parseCtx, lastCmd *cli.Command) (err error) { //nolint:revive,unused
Expand Down
5 changes: 3 additions & 2 deletions cli/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (

"gopkg.in/hedzr/errors.v3"

"github.com/hedzr/cmdr/v2/cli"
"github.com/hedzr/cmdr/v2/conf"
logz "github.com/hedzr/logg/slog"
"github.com/hedzr/store"

"github.com/hedzr/cmdr/v2/cli"
"github.com/hedzr/cmdr/v2/conf"
)

func New(c *cli.Config, opts ...wOpt) *workerS {
Expand Down
3 changes: 2 additions & 1 deletion examples/demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package main
import (
logz "github.com/hedzr/logg/slog"

"github.com/hedzr/store"

"github.com/hedzr/cmdr/v2"
"github.com/hedzr/cmdr/v2/cli"
"github.com/hedzr/cmdr/v2/loaders"
"github.com/hedzr/cmdr/v2/pkg/dir"
"github.com/hedzr/store"
)

func main() {
Expand Down
5 changes: 3 additions & 2 deletions examples/large/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package main

import (
logz "github.com/hedzr/logg/slog"
"github.com/hedzr/store"

"github.com/hedzr/cmdr/v2"
"github.com/hedzr/cmdr/v2/cli"
"github.com/hedzr/cmdr/v2/examples"
"github.com/hedzr/cmdr/v2/loaders"
logz "github.com/hedzr/logg/slog"
"github.com/hedzr/store"
)

func main() {
Expand Down
7 changes: 4 additions & 3 deletions examples/more.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"os"
"os/exec"

"github.com/hedzr/cmdr/v2/cli"
"github.com/hedzr/cmdr/v2/pkg/dir"
"github.com/hedzr/cmdr/v2/pkg/text"
"github.com/hedzr/is"
"github.com/hedzr/is/term"
logz "github.com/hedzr/logg/slog" //nolint:gci

"github.com/hedzr/cmdr/v2/cli"
"github.com/hedzr/cmdr/v2/pkg/dir"
"github.com/hedzr/cmdr/v2/pkg/text"
)

func AttachServerCommand(parent cli.CommandBuilder) { //nolint:revive
Expand Down
3 changes: 2 additions & 1 deletion loaders/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package loaders
import (
"context"

"github.com/hedzr/cmdr/v2/cli"
logz "github.com/hedzr/logg/slog"
"github.com/hedzr/store"
"github.com/hedzr/store/providers/env"

"github.com/hedzr/cmdr/v2/cli"
)

func NewEnvVarLoader() *envvarloader {
Expand Down
5 changes: 3 additions & 2 deletions loaders/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (

logz "github.com/hedzr/logg/slog"

"github.com/hedzr/cmdr/v2/cli"
"github.com/hedzr/cmdr/v2/pkg/dir"
"github.com/hedzr/store"
"github.com/hedzr/store/codecs/hcl"
"github.com/hedzr/store/codecs/hjson"
Expand All @@ -18,6 +16,9 @@ import (
"github.com/hedzr/store/codecs/toml"
"github.com/hedzr/store/codecs/yaml"
"github.com/hedzr/store/providers/file"

"github.com/hedzr/cmdr/v2/cli"
"github.com/hedzr/cmdr/v2/pkg/dir"
)

const confSubFolderName = "conf.d"
Expand Down

0 comments on commit 3bacf6a

Please sign in to comment.