Skip to content

Commit

Permalink
refactor: rename file name at internal/pkg_kit
Browse files Browse the repository at this point in the history
  • Loading branch information
sinlov committed Mar 26, 2024
1 parent b3ff76e commit e3555d7
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
14 changes: 7 additions & 7 deletions cmd/cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"github.com/bridgewwater/temp-golang-cli-fast/command"
"github.com/bridgewwater/temp-golang-cli-fast/command/subcommand_new"
"github.com/bridgewwater/temp-golang-cli-fast/internal/pkgJson"
"github.com/bridgewwater/temp-golang-cli-fast/internal/pkg_kit"
"github.com/bridgewwater/temp-golang-cli-fast/internal/urfave_cli"
"github.com/bridgewwater/temp-golang-cli-fast/internal/urfave_cli/cli_exit_urfave"
"github.com/urfave/cli/v2"
Expand All @@ -21,14 +21,14 @@ func NewCliApp() *cli.App {
cli_exit_urfave.ChangeDefaultExitCode(defaultExitCode)
app := cli.NewApp()
app.EnableBashCompletion = true
app.Version = pkgJson.GetPackageJsonVersionGoStyle(false)
app.Name = pkgJson.GetPackageJsonName()
if pkgJson.GetPackageJsonHomepage() != "" {
app.Usage = fmt.Sprintf("see: %s", pkgJson.GetPackageJsonHomepage())
app.Version = pkg_kit.GetPackageJsonVersionGoStyle(false)
app.Name = pkg_kit.GetPackageJsonName()
if pkg_kit.GetPackageJsonHomepage() != "" {
app.Usage = fmt.Sprintf("see: %s", pkg_kit.GetPackageJsonHomepage())
}
app.Description = pkgJson.GetPackageJsonDescription()
app.Description = pkg_kit.GetPackageJsonDescription()
year := time.Now().Year()
jsonAuthor := pkgJson.GetPackageJsonAuthor()
jsonAuthor := pkg_kit.GetPackageJsonAuthor()
app.Copyright = fmt.Sprintf("© %s-%d %s by: %s, run on %s %s",
copyrightStartYear, year, jsonAuthor.Name, runtime.Version(), runtime.GOOS, runtime.GOARCH)
author := &cli.Author{
Expand Down
4 changes: 2 additions & 2 deletions cmd/temp-golang-cli-fast/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"github.com/bridgewwater/temp-golang-cli-fast"
"github.com/bridgewwater/temp-golang-cli-fast/cmd/cli"
"github.com/bridgewwater/temp-golang-cli-fast/internal/pkgJson"
"github.com/bridgewwater/temp-golang-cli-fast/internal/pkg_kit"
"github.com/gookit/color"
os "os"
)
Expand All @@ -16,7 +16,7 @@ const (
)

func main() {
pkgJson.InitPkgJsonContent(temp_golang_cli_fast.PackageJson)
pkg_kit.InitPkgJsonContent(temp_golang_cli_fast.PackageJson)

app := cli.NewCliApp()

Expand Down
6 changes: 3 additions & 3 deletions command/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/bar-counter/slog"
"github.com/bridgewwater/temp-golang-cli-fast/constant"
"github.com/bridgewwater/temp-golang-cli-fast/internal/log"
"github.com/bridgewwater/temp-golang-cli-fast/internal/pkgJson"
"github.com/bridgewwater/temp-golang-cli-fast/internal/pkg_kit"
"github.com/bridgewwater/temp-golang-cli-fast/internal/urfave_cli/cli_exit_urfave"
"github.com/urfave/cli/v2"
)
Expand Down Expand Up @@ -76,11 +76,11 @@ func GlobalBeforeAction(c *cli.Context) error {
if err != nil {
panic(err)
}
cliVersion := pkgJson.GetPackageJsonVersionGoStyle(false)
cliVersion := pkg_kit.GetPackageJsonVersionGoStyle(false)
if isVerbose {
slog.Warnf("-> open verbose, and now command version is: %s", cliVersion)
}
appName := pkgJson.GetPackageJsonName()
appName := pkg_kit.GetPackageJsonName()
cmdGlobalEntry, err = withGlobalFlag(c, cliVersion, appName)
if err != nil {
return cli_exit_urfave.Err(err)
Expand Down
2 changes: 1 addition & 1 deletion command/global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func TestPanicGlobal_init_without_package_json(t *testing.T) {
// mock TestPanicGlobal_init_without_package_json

errString := "pkgJson must use InitPkgJsonContent(content), then use"
errString := "pkg_kit must use InitPkgJsonContent(content), then use"

if !assert.PanicsWithError(t, errString, func() {
// do TestPanicGlobal_init_without_package_json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pkgJson
package pkg_kit

import (
"encoding/json"
Expand Down Expand Up @@ -71,7 +71,7 @@ func GetPackageJsonDescription() string {

func checkPackageJsonLoad() {
if pkgJsonContent == "" {
panic(fmt.Errorf("pkgJson must use InitPkgJsonContent(content), then use"))
panic(fmt.Errorf("pkg_kit must use InitPkgJsonContent(content), then use"))
}
if pkgJson == nil {
initJsonContent()
Expand All @@ -85,19 +85,19 @@ func initJsonContent() {
pkgJ := PkgJson{}
err := json.Unmarshal([]byte(pkgJsonContent), &pkgJ)
if err != nil {
panic(fmt.Errorf("pkgJson parse package.json err: %v", err))
panic(fmt.Errorf("pkg_kit parse package.json err: %v", err))
}
if pkgJ.Name == "" {
panic(fmt.Errorf("pkgJson parse package.json name is empty"))
panic(fmt.Errorf("pkg_kit parse package.json name is empty"))
}
if pkgJ.Version == "" {
panic(fmt.Errorf("pkgJson parse package.json version is empty"))
panic(fmt.Errorf("pkg_kit parse package.json version is empty"))
}
if pkgJ.Author.Name == "" {
panic(fmt.Errorf("pkgJson parse package.json author name is empty"))
panic(fmt.Errorf("pkg_kit parse package.json author name is empty"))
}
if pkgJ.Author.Email == "" {
panic(fmt.Errorf("pkgJson parse package.json author email is empty"))
panic(fmt.Errorf("pkg_kit parse package.json author email is empty"))
}
pkgJson = &pkgJ
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pkgJson
package pkg_kit

import (
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -98,7 +98,7 @@ func TestPanicInitPkgJsonContentError(t *testing.T) {
func TestPanicPackageJsonLoadName(t *testing.T) {
// mock TestPanicPackageJsonLoadName

errString := "pkgJson parse package.json name is empty"
errString := "pkg_kit parse package.json name is empty"

if !assert.PanicsWithError(t, errString, func() {
// do TestPanicPackageJsonLoadName
Expand All @@ -115,7 +115,7 @@ func TestPanicPackageJsonLoadName(t *testing.T) {
func TestPanicPackageJsonLoadVersion(t *testing.T) {
// mock TestPanicPackageJsonLoadVersion

errString := "pkgJson parse package.json version is empty"
errString := "pkg_kit parse package.json version is empty"

if !assert.PanicsWithError(t, errString, func() {
// do TestPanicPackageJsonLoadVersion
Expand All @@ -132,7 +132,7 @@ func TestPanicPackageJsonLoadVersion(t *testing.T) {
func TestPanicPackageJsonLoadAuthor(t *testing.T) {
// mock TestPanicPackageJsonLoadAuthor

errString := "pkgJson parse package.json author name is empty"
errString := "pkg_kit parse package.json author name is empty"

if !assert.PanicsWithError(t, errString, func() {
// do TestPanicPackageJsonLoadAuthor
Expand All @@ -146,7 +146,7 @@ func TestPanicPackageJsonLoadAuthor(t *testing.T) {
t.Fatalf("TestPanicPackageJsonLoadAuthor should panic")
}

errString = "pkgJson parse package.json author email is empty"
errString = "pkg_kit parse package.json author email is empty"

if !assert.PanicsWithError(t, errString, func() {
// do TestPanicPackageJsonLoadAuthor
Expand Down

0 comments on commit e3555d7

Please sign in to comment.