diff --git a/base/commands/config/config_add.go b/base/commands/config/config_add.go index d15138c4..39949e88 100644 --- a/base/commands/config/config_add.go +++ b/base/commands/config/config_add.go @@ -18,11 +18,28 @@ import ( type AddCmd struct{} func (cm AddCmd) Init(cc plug.InitContext) error { - cc.SetCommandUsage("add TARGET") + cc.SetCommandUsage("add [configuration-name]") short := "Adds a configuration" long := `Adds a configuration with the given name/path and KEY=VALUE pairs Overrides the previous configuration if it exists. + +The following keys are supported: + + * cluster.name STRING + * cluster.address STRING + * cluster.user STRING + * cluster.password STRING + * cluster.discovery-token STRING + * ssl.enabled BOOLEAN (true / false) + * ssl.server STRING + * ssl.skip-verify BOOLEAN (true / false) + * ssl.ca-path STRING + * ssl.key-path STRING + * ssl.key-password STRING + * log.path STRING + * log.level ENUM (error / warn / info / debug) + ` cc.SetCommandHelp(long, short) cc.SetPositionalArgCount(1, math.MaxInt) diff --git a/base/commands/config/config_import.go b/base/commands/config/config_import.go index 9c209116..6c4efc85 100644 --- a/base/commands/config/config_import.go +++ b/base/commands/config/config_import.go @@ -15,9 +15,27 @@ import ( type ImportCmd struct{} func (cm ImportCmd) Init(cc plug.InitContext) error { - cc.SetCommandUsage("import TARGET SOURCE") - help := "Imports configuration from an arbitrary source" - cc.SetCommandHelp(help, help) + cc.SetCommandUsage("import [configuration-name] [source]") + short := "Imports configuration from an arbitrary source" + long := `Imports configuration from an arbitrary source + +Currently importing only Viridian connection configuration is supported. + +1. On Viridian console, visit: + + Dashboard -> Connect Client -> Quick connection guide -> Go + +2. Copy the text in box 1 and pass it as the second parameter. + Make sure the text is quoted before running: + + clc config import my-config "curl https://api.viridian.hazelcast.com ... default.zip" + +Alternatively, you can use an already downloaded Go client sample: + + clc config import my-config /home/me/Downloads/hazelcast-cloud-go-sample....zip + +` + cc.SetCommandHelp(long, short) cc.SetPositionalArgCount(2, 2) return nil } diff --git a/base/commands/home.go b/base/commands/home.go index 5f6230be..58dc0347 100644 --- a/base/commands/home.go +++ b/base/commands/home.go @@ -19,7 +19,7 @@ func (hc HomeCommand) Init(cc plug.InitContext) error { help := "Print the CLC home directory, optionally by joining the given sub-paths" cc.SetCommandHelp(help, help) cc.SetPositionalArgCount(0, math.MaxInt) - cc.SetCommandUsage("home [SUBPATH ...] [flags]") + cc.SetCommandUsage("home [subpath ...] [flags]") return nil } diff --git a/base/commands/map/map.go b/base/commands/map/map.go index 8e18df91..c2b3d08c 100644 --- a/base/commands/map/map.go +++ b/base/commands/map/map.go @@ -31,7 +31,7 @@ func (mc *MapCommand) Init(cc plug.InitContext) error { cc.AddStringFlag(clc.PropertySchemaDir, "", paths.Schemas(), false, "set the schema directory") } cc.SetTopLevel(true) - cc.SetCommandUsage("map COMMAND [flags]") + cc.SetCommandUsage("map [command] [flags]") help := "Map operations" cc.SetCommandHelp(help, help) return nil diff --git a/base/commands/map/map_clear.go b/base/commands/map/map_clear.go index 1940d290..1cde355f 100644 --- a/base/commands/map/map_clear.go +++ b/base/commands/map/map_clear.go @@ -19,7 +19,7 @@ type MapClearCommand struct{} func (mc *MapClearCommand) Init(cc plug.InitContext) error { help := "Delete all entries of a Map" cc.SetCommandHelp(help, help) - cc.SetCommandUsage("clear [-n MAP] [flags]") + cc.SetCommandUsage("clear [-n map-name] [flags]") return nil } diff --git a/base/commands/map/map_entry_set.go b/base/commands/map/map_entry_set.go index cf0b7cb5..c3a36ea9 100644 --- a/base/commands/map/map_entry_set.go +++ b/base/commands/map/map_entry_set.go @@ -21,7 +21,7 @@ type MapEntrySetCommand struct{} func (mc *MapEntrySetCommand) Init(cc plug.InitContext) error { help := "Get all entries of a Map" cc.SetCommandHelp(help, help) - cc.SetCommandUsage("entry-set [-n MAP] [flags]") + cc.SetCommandUsage("entry-set [-n map-name] [flags]") cc.SetPositionalArgCount(0, 0) return nil } @@ -44,7 +44,13 @@ func (mc *MapEntrySetCommand) Exec(ctx context.Context, ec plug.ExecContext) err stop() pairs := codec.DecodeMapEntrySetResponse(rv.(*hazelcast.ClientMessage)) rows := output.DecodePairs(ci, pairs, showType) - return ec.AddOutputRows(ctx, rows...) + if len(rows) > 0 { + return ec.AddOutputRows(ctx, rows...) + } + if !ec.Props().GetBool(clc.PropertyQuite) { + I2(fmt.Fprintln(ec.Stdout(), "No entries found")) + } + return nil } func init() { diff --git a/base/commands/map/map_get.go b/base/commands/map/map_get.go index ac12f71e..d9bde220 100644 --- a/base/commands/map/map_get.go +++ b/base/commands/map/map_get.go @@ -22,7 +22,7 @@ func (mc *MapGetCommand) Init(cc plug.InitContext) error { addKeyTypeFlag(cc) help := "Get a value from the given Map" cc.SetCommandHelp(help, help) - cc.SetCommandUsage("get [-n MAP] KEY [flags]") + cc.SetCommandUsage("get [-n map-name] [key] [flags]") cc.SetPositionalArgCount(1, 1) return nil } diff --git a/base/commands/map/map_remove.go b/base/commands/map/map_remove.go index 6c2317fd..07ca2ded 100644 --- a/base/commands/map/map_remove.go +++ b/base/commands/map/map_remove.go @@ -22,7 +22,7 @@ func (mc *MapRemoveCommand) Init(cc plug.InitContext) error { addKeyTypeFlag(cc) help := "Remove a value from the given Map" cc.SetCommandHelp(help, help) - cc.SetCommandUsage("remove [-n MAP] KEY [flags]") + cc.SetCommandUsage("remove [-n map-name] [key] [flags]") cc.SetPositionalArgCount(1, 1) return nil } diff --git a/base/commands/map/map_set.go b/base/commands/map/map_set.go index 9a8ef427..ee8d8ce0 100644 --- a/base/commands/map/map_set.go +++ b/base/commands/map/map_set.go @@ -24,7 +24,7 @@ func (mc *MapSetCommand) Init(cc plug.InitContext) error { cc.SetPositionalArgCount(2, 2) help := "Set a value in the given Map" cc.SetCommandHelp(help, help) - cc.SetCommandUsage("set [-n MAP] KEY VALUE [flags]") + cc.SetCommandUsage("set [-n MAP] [key] [value] [flags]") return nil } diff --git a/base/commands/map/map_size.go b/base/commands/map/map_size.go index 1ac0bef5..05462184 100644 --- a/base/commands/map/map_size.go +++ b/base/commands/map/map_size.go @@ -20,7 +20,7 @@ type MapSizeCommand struct{} func (mc *MapSizeCommand) Init(cc plug.InitContext) error { help := "Return the size of the given Map" cc.SetCommandHelp(help, help) - cc.SetCommandUsage("size [-n MAP]") + cc.SetCommandUsage("size [-n map-name]") cc.SetPositionalArgCount(0, 0) return nil } diff --git a/base/commands/object/object_list.go b/base/commands/object/object_list.go index 2b6108cc..a7f5d85c 100644 --- a/base/commands/object/object_list.go +++ b/base/commands/object/object_list.go @@ -51,11 +51,6 @@ var objTypes = []string{ Cache, EventJournal, Ringbuffer, - FencedLock, - ISemaphore, - IAtomicLong, - IAtomicReference, - ICountdownLatch, CardinalityEstimator, } @@ -70,7 +65,9 @@ func (cm ObjectListCommand) Init(cc plug.InitContext) error { long := fmt.Sprintf(`List distributed objects, optionally filter by type. The object-type filter may be one of: + %s +CP objects such as AtomicLong cannot be listed. `, objectFilterTypes()) cc.SetCommandHelp(long, "List distributed objects") cc.AddBoolFlag(flagShowHidden, "", false, false, "show hidden and system objects") @@ -108,7 +105,13 @@ func (cm ObjectListCommand) Exec(ctx context.Context, ec plug.ExecContext) error valueCol, }) } - return ec.AddOutputRows(ctx, rows...) + if len(rows) > 0 { + return ec.AddOutputRows(ctx, rows...) + } + if !ec.Props().GetBool(clc.PropertyQuite) { + I2(fmt.Fprintln(ec.Stdout(), "No objects found")) + } + return nil } func objectFilterTypes() string { diff --git a/base/commands/sql/common.go b/base/commands/sql/common.go index 591c7e15..b9dc4d5e 100644 --- a/base/commands/sql/common.go +++ b/base/commands/sql/common.go @@ -45,6 +45,7 @@ func UpdateOutput(ctx context.Context, ec plug.ExecContext, res sql.Result, verb errCh <- err break } + // TODO: move the following 2 lines out of the loop --YT cols := row.Metadata().Columns() orow := make(output.Row, len(cols)) for i, col := range cols { diff --git a/base/commands/sql/sql.go b/base/commands/sql/sql.go index ee83ad50..0a69c8bd 100644 --- a/base/commands/sql/sql.go +++ b/base/commands/sql/sql.go @@ -32,7 +32,7 @@ func (cm *SQLCommand) Init(cc plug.InitContext) error { if cc.Interactive() { return errors.ErrNotAvailable } - cc.SetCommandUsage("sql [QUERY] [flags]") + cc.SetCommandUsage("sql [query] [flags]") cc.SetPositionalArgCount(1, 1) cc.AddCommandGroup("sql", "SQL") cc.SetCommandGroup("sql") diff --git a/clc/cmd/exec_context.go b/clc/cmd/exec_context.go index 3540b0f1..1020c311 100644 --- a/clc/cmd/exec_context.go +++ b/clc/cmd/exec_context.go @@ -256,9 +256,9 @@ func (ec *ExecContext) Wrap(f func() error) error { } var msg string if verbose || ec.Interactive() { - msg = fmt.Sprintf("\nOK (%d ms)", took.Milliseconds()) + msg = fmt.Sprintf("OK (%d ms)", took.Milliseconds()) } else { - msg = "\nOK" + msg = "OK" } I2(fmt.Fprintln(ec.stdout, msg)) return nil diff --git a/clc/config/config.go b/clc/config/config.go index c83548b0..18fb201e 100644 --- a/clc/config/config.go +++ b/clc/config/config.go @@ -63,9 +63,6 @@ func MakeHzConfig(props plug.ReadOnlyProperties, lg log.Logger) (hazelcast.Confi var viridianEnabled bool if vt := props.GetString(clc.PropertyClusterDiscoveryToken); vt != "" { lg.Debugf("Viridan token: XXX") - if err := os.Setenv(clc.EnvHzCloudCoordinatorBaseURL, clc.ViridianCoordinatorURL); err != nil { - return cfg, fmt.Errorf("setting coordinator URL") - } cfg.Cluster.Cloud.Enabled = true cfg.Cluster.Cloud.Token = vt viridianEnabled = true diff --git a/clc/config/wizard/input.go b/clc/config/wizard/input.go index 4f60bb8d..36858176 100644 --- a/clc/config/wizard/input.go +++ b/clc/config/wizard/input.go @@ -120,10 +120,27 @@ func (m textModel) View() string { return "" } var b strings.Builder - b.WriteString( - "There is no configuration detected. You can register a new configuration to connect Hazelcast cluster.\n" + - "You can connect to Viridian cluster using curl request from `Dashboard -> Connect Client -> Quick connection guide -> Go` tab.\n" + - "Paste the link to source field below and it will download the config and TLS files.\n\n") + b.WriteString(`There is no configuration detected. + +This screen helps you create a new connection configuration. +Note that this screen supports only Viridian clusters. +For other clusters use the following command: + + clc config add --help + +1. Enter the desired name in the "Configuration Name" field. +2. On Viridian console, visit: + + Dashboard -> Connect Client -> Quick connection guide -> Go + +3. Copy the text in box 1 and paste it in the "Source" field. +4. Navigate to the [Submit] button and press enter. + +Alternatively, you can use the following command: + + clc config import --help + +`) for i := range m.inputs { b.WriteString(m.inputs[i].View()) if i < len(m.inputs)-1 { diff --git a/go.mod b/go.mod index f63172b8..43dccffa 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/alecthomas/chroma v0.10.0 github.com/gohxs/readline v0.0.0-20171011095936-a780388e6e7c github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 - github.com/hazelcast/hazelcast-go-client v1.4.0 + github.com/hazelcast/hazelcast-go-client v1.4.1-0.20230404141417-cffc4cae7feb github.com/mattn/go-runewidth v0.0.14 github.com/nathan-fiscaletti/consolesize-go v0.0.0-20210105204122-a87d9f614b9d github.com/spf13/cobra v1.6.0 @@ -67,5 +67,3 @@ require ( github.com/nyaosorg/go-readline-ny v0.8.3 gopkg.in/yaml.v2 v2.4.0 ) - -replace github.com/hazelcast/hazelcast-go-client v1.4.0 => github.com/yuce/hazelcast-go-client v1.1.2-0.20230404141417-cffc4cae7feb