Skip to content

Commit

Permalink
[CLC-429]: Change cancel message on dmt start command (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
kutluhanmetin authored Nov 14, 2023
1 parent 1af0ff2 commit 0311870
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
7 changes: 6 additions & 1 deletion base/commands/migration/migration_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"

"github.com/hazelcast/hazelcast-commandline-client/clc"
"github.com/hazelcast/hazelcast-commandline-client/clc/cmd"
"github.com/hazelcast/hazelcast-commandline-client/clc/paths"
"github.com/hazelcast/hazelcast-commandline-client/clc/ux/stage"
clcerrors "github.com/hazelcast/hazelcast-commandline-client/errors"
Expand All @@ -33,11 +34,15 @@ func (StartCmd) Init(cc plug.InitContext) error {
}

func (StartCmd) Exec(ctx context.Context, ec plug.ExecContext) (err error) {
cmd.SetCancelMsg(" (Ctrl+C to exit) ")
ec.PrintlnUnnecessary("")
ec.PrintlnUnnecessary(`Hazelcast Data Migration Tool v5.3.0
(c) 2023 Hazelcast, Inc.
Selected data structures in the source cluster will be migrated to the target cluster.
Selected data structures in the source cluster will be migrated to the target cluster.
Exiting the application does not affect the migration progress.
In order to cancel the migration, use the 'cancel' command.
`)
conf := ec.GetStringArg(argDMTConfig)
if !paths.Exists(conf) {
Expand Down
18 changes: 15 additions & 3 deletions clc/cmd/exec_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,22 @@ import (
"github.com/hazelcast/hazelcast-commandline-client/internal/types"
)

const (
cancelMsg = " (Ctrl+C to cancel) "
var (
cancelMsg atomic.Value
)

func SetCancelMsg(msg string) {
cancelMsg.Store(msg)
}

func GetCancelMsg() string {
return cancelMsg.Load().(string)
}

func init() {
SetCancelMsg(" (Ctrl+C to cancel) ")
}

type ClientFn func(ctx context.Context, cfg hazelcast.Config) (*hazelcast.ClientInternal, error)

type ExecContext struct {
Expand Down Expand Up @@ -409,7 +421,7 @@ func (s *simpleSpinner) SetText(text string) {
s.sp.Prefix("")
return
}
s.sp.Prefix(" " + text + cancelMsg)
s.sp.Prefix(" " + text + GetCancelMsg())
}

func (s *simpleSpinner) SetProgress(progress float32) {
Expand Down

0 comments on commit 0311870

Please sign in to comment.