Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
iychoi committed Oct 23, 2024
1 parent 77d3c3b commit 1bd1f43
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 1 addition & 2 deletions cmd/flag/common.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package flag

import (
"fmt"
"os"

irodsclient_config "github.com/cyverse/go-irodsclient/config"
Expand Down Expand Up @@ -34,7 +33,7 @@ var (
)

func SetCommonFlags(command *cobra.Command, noResource bool) {
command.Flags().StringVarP(&commonFlagValues.ConfigFilePath, "config", "c", "", fmt.Sprintf("Set config file or directory (default %q)", commons.GetDefaultIRODSConfigPath()))
command.Flags().StringVarP(&commonFlagValues.ConfigFilePath, "config", "c", commons.GetDefaultIRODSConfigPath(), "Set config file or directory")
command.Flags().BoolVarP(&commonFlagValues.ShowVersion, "version", "v", false, "Print version")
command.Flags().BoolVarP(&commonFlagValues.ShowHelp, "help", "h", false, "Print help")
command.Flags().BoolVarP(&commonFlagValues.DebugMode, "debug", "d", false, "Enable debug mode")
Expand Down
6 changes: 4 additions & 2 deletions commons/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import (
)

const (
goCommandsRepoPackagePath string = "cyverse/gocommands"

ClientProgramName string = "gocommands"
FilesystemTimeout irodsclient_types.Duration = irodsclient_types.Duration(10 * time.Minute)
TransferThreadNumDefault int = 5
UploadThreadNumMax int = 20
TCPBufferSizeDefault int = 4 * 1024 * 1024
TCPBufferSizeStringDefault string = "4MB"
TCPBufferSizeDefault int = 1 * 1024 * 1024
TCPBufferSizeStringDefault string = "1MB"
RedirectToResourceMinSize int64 = 1024 * 1024 * 1024 // 1GB
)
8 changes: 4 additions & 4 deletions commons/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ func CheckNewRelease() (*selfupdate.Release, error) {

logger.Infof("checking latest version for %s/%s", runtime.GOOS, runtime.GOARCH)

latest, found, err := selfupdate.DetectLatest(context.Background(), selfupdate.ParseSlug("cyverse/gocommands"))
latest, found, err := selfupdate.DetectLatest(context.Background(), selfupdate.ParseSlug(goCommandsRepoPackagePath))
if err != nil {
return nil, xerrors.Errorf("error occurred while detecting version: %w", err)
}

if !found {
return nil, xerrors.Errorf("latest version for %s/%s could not be found from github repository 'cyverse/gocommands'", runtime.GOOS, runtime.GOARCH)
return nil, xerrors.Errorf("latest version for %s/%s is not found from github repository %q", runtime.GOOS, runtime.GOARCH, goCommandsRepoPackagePath)
}

return latest, nil
Expand All @@ -38,13 +38,13 @@ func SelfUpgrade() error {

logger.Infof("checking latest version for %s/%s", runtime.GOOS, runtime.GOARCH)

latest, found, err := selfupdate.DetectLatest(context.Background(), selfupdate.ParseSlug("cyverse/gocommands"))
latest, found, err := selfupdate.DetectLatest(context.Background(), selfupdate.ParseSlug(goCommandsRepoPackagePath))
if err != nil {
return xerrors.Errorf("error occurred while detecting version: %w", err)
}

if !found {
return xerrors.Errorf("latest version for %s/%s could not be found from github repository 'cyverse/gocommands'", runtime.GOOS, runtime.GOARCH)
return xerrors.Errorf("latest version for %s/%s could not be found from github repository %q", runtime.GOOS, runtime.GOARCH, goCommandsRepoPackagePath)
}

myVersion := GetClientVersion()
Expand Down

0 comments on commit 1bd1f43

Please sign in to comment.