Skip to content

Commit

Permalink
renamed cmd package to command.
Browse files Browse the repository at this point in the history
  • Loading branch information
bengarrett committed Sep 2, 2024
1 parent a87c85d commit 27a758a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cmd/cmd.go → command/command.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Package cmd provides the command line interface for the Defacto2 server application.
// Package command provides the command line interface for the Defacto2 server application.
// With the configuration of the application done using the environment variables,
// the use of commands should be kept to a minimum.
package cmd
package command

import (
"errors"
Expand Down
12 changes: 6 additions & 6 deletions cmd/cmd_test.go → command/command_test.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package cmd_test
package command_test

import (
"testing"

"github.com/Defacto2/server/cmd"
"github.com/Defacto2/server/command"
"github.com/Defacto2/server/internal/config"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestRun(t *testing.T) {
t.Parallel()
ec, err := cmd.Run("", nil)
ec, err := command.Run("", nil)
require.Error(t, err)
assert.Equal(t, cmd.UsageError, ec)
assert.Equal(t, command.UsageError, ec)
c := config.Config{}
ec, err = cmd.Run("", &c)
ec, err = command.Run("", &c)
require.Error(t, err)
assert.Equal(t, cmd.GenericError, ec)
assert.Equal(t, command.GenericError, ec)
}
8 changes: 4 additions & 4 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"time"

"github.com/Defacto2/helper"
"github.com/Defacto2/server/cmd"
"github.com/Defacto2/server/command"
"github.com/Defacto2/server/handler/app"
"github.com/Defacto2/server/handler/download"
"github.com/Defacto2/server/handler/html3"
Expand Down Expand Up @@ -150,15 +150,15 @@ func (c Configuration) Info(logger *zap.SugaredLogger, w io.Writer) {
fmt.Fprint(w, "\n\n")
}

fmt.Fprintf(w, " %s.\n", cmd.Copyright())
fmt.Fprintf(w, " %s.\n", command.Copyright())
fmt.Fprintf(w, "%s\n", c.versionBrief())

cpuInfo := fmt.Sprintf(" %d active routines sharing %d usable threads on %d CPU cores.",
runtime.NumGoroutine(), runtime.GOMAXPROCS(-1), runtime.NumCPU())
fmt.Fprintln(w, cpuInfo)

golangInfo := fmt.Sprintf(" Compiled on Go %s for %s with %s.\n",
runtime.Version()[2:], cmd.OS(), cmd.Arch())
runtime.Version()[2:], command.OS(), command.Arch())
fmt.Fprintln(w, golangInfo)
//
// All additional feedback should go in internal/config/check.go (c *Config) Checks()
Expand Down Expand Up @@ -380,7 +380,7 @@ func (c Configuration) versionBrief() string {
if c.Version == "" {
return " no version info, app compiled binary directly."
}
return fmt.Sprintf(" %s.", cmd.Commit(c.Version))
return fmt.Sprintf(" %s.", command.Commit(c.Version))
}

// Rewrites for assets.
Expand Down
8 changes: 4 additions & 4 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"strings"

"github.com/Defacto2/helper"
"github.com/Defacto2/server/cmd"
"github.com/Defacto2/server/command"
"github.com/Defacto2/server/handler"
"github.com/Defacto2/server/internal/config"
"github.com/Defacto2/server/internal/postgres"
Expand Down Expand Up @@ -142,7 +142,7 @@ func newInstance(ctx context.Context, db *sql.DB, configs config.Config) handler
View: view,
}
if c.Version == "" {
c.Version = cmd.Commit("")
c.Version = command.Commit("")
}
if ctx != nil && db != nil {
c.RecordCount = config.RecordCount(ctx, db)
Expand All @@ -157,12 +157,12 @@ func parseFlags(logger *zap.SugaredLogger, configs config.Config) int {
if logger == nil {
return -1
}
code, err := cmd.Run(version, &configs)
code, err := command.Run(version, &configs)
if err != nil {
logger.Errorf("run command, parse flags: %s", err)
return int(code)
}
useExitCode := code >= cmd.ExitOK
useExitCode := code >= command.ExitOK
if useExitCode {
return int(code)
}
Expand Down

0 comments on commit 27a758a

Please sign in to comment.