Skip to content

Commit

Permalink
Merge branch 'main' into CLC-219
Browse files Browse the repository at this point in the history
# Conflicts:
#	base/commands/shell.go
  • Loading branch information
kutluhanmetin committed Sep 18, 2023
2 parents 9843de7 + 61a54c4 commit d5a9311
Show file tree
Hide file tree
Showing 203 changed files with 5,252 additions and 5,007 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_release-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: "Set up Go"
uses: "actions/setup-go@v3"
with:
go-version: "1.19"
go-version: "1.21"

- name: "Download Inno Setup installer"
run: "curl -L -o installer.exe http://files.jrsoftware.org/is/6/innosetup-${{ env.INNO_VERSION }}.exe"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: "Set up Go"
uses: "actions/setup-go@v3"
with:
go-version: "1.19"
go-version: "1.21"

- name: "Build the Project"
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage_runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.19'
go-version: '1.21'

- name: Install JDK
uses: actions/setup-java@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- name: "Setup Go"
uses: "actions/setup-go@v3"
with:
go-version: "1.19"
go-version: "1.21"

- name: "Install Go tools"
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-all-386.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: "Setup Go"
uses: "actions/setup-go@v3"
with:
go-version: "1.19"
go-version: "1.21"

- name: "Install Go tools"
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: "Setup Go"
uses: "actions/setup-go@v3"
with:
go-version: "1.19"
go-version: "1.21"

- name: "Install Go Tools"
run: |
Expand Down
45 changes: 26 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,40 @@

## Installation

We provide binaries for the popular platforms at our [Releases](https://github.com/hazelcast/hazelcast-commandline-client/releases) page.
In order to install CLC:

* Download the release package for your platform,
* Extract it,
* Optionally move the `clc` binary to somewhere in your *PATH*, so it can be run in any terminal without additional settings.

Currently we provide precompiled binaries of CLC for the following platforms and architectures:

* Linux/amd64
* Windows/amd64
* MacOS/amd64
* MacOS/arm64
* macOS/amd64
* macOS/arm64

Additionally, we provide an installer for Windows 10 and up.
The installer can install CLC for either system-wide or just for the user.
It adds the `clc` binary automatically to the `$PATH`, so it can be run in any terminal without additional settings.
### Linux / macOS

You can run the following command to install the latest stable CLC on a computer running Linux x64 or macOS 10.15 (Catalina) x64/ARM 64 (M1/M2):
```
curl -sL https://raw.githubusercontent.com/hazelcast/hazelcast-commandline-client/main/extras/unix/install.sh | bash
```

On MacOS, you may need to remove the CLC binary from quarantine, if you get a security warning:
On macOS, binaries downloaded outside of AppStore require your intervention to run.
The install script automatically handles this, but if you downloaded a release package you can do it manually:
```
$ xattr -d com.apple.quarantine CLC_FOLDER/clc
```
Use the correct path instead of `CLC_FOLDER` in the command above.

### Windows

We provide an installer for Windows 10 and up.
The installer can install CLC either system-wide or just for the user.
It adds the `clc` binary automatically to the `$PATH`, so it can be run in any terminal without additional settings.

Check out our [Releases](https://github.com/hazelcast/hazelcast-commandline-client/releases/latest) page for the download.

### Building from Source

If your platform is not one of the above, you may want to compile CLC yourself. Our build process is very simple and doesn't have many dependencies.
In most cases just running `make` is sufficient to build CLC if you have the latest [Go](https://go.dev/) compiler installed.
See [Building from source](#building-from-source) section.
In most cases, running `make` is sufficient to build CLC if you have the latest [Go](https://go.dev/) compiler and GNU make installed.
See [Building from source](#building-from-source) section for detailed instructions.

## Usage Summary

Expand Down Expand Up @@ -202,14 +209,14 @@ The following targets are tested and supported.
The prior versions of the given targets would also work, but that's not tested.

* Ubuntu 22.04 or better.
* MacOS 12 or better.
* macOS 15 or better.
* Windows 10 or better.

### Requirements

* Go 1.19 or better
* Go 1.21 or better
* Git
* GNU Make (on Linux and MacOS)
* GNU Make (on Linux and macOS)
* Command Prompt or Powershell (on Windows)
* go-winres: https://github.com/tc-hib/go-winres (on Windows)

Expand All @@ -236,7 +243,7 @@ The `clc` or `clc.exe` binary is created in the `build` directory.

CLC starts the in interactive mode by default.

On Linux and MacOS:
On Linux and macOS:
```
./build/clc
```
Expand Down
54 changes: 9 additions & 45 deletions base/commands/atomic_long/atomic_long.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,30 @@ package atomiclong

import (
"context"
"fmt"

"github.com/hazelcast/hazelcast-go-client"

"github.com/hazelcast/hazelcast-commandline-client/base"
"github.com/hazelcast/hazelcast-commandline-client/clc"
. "github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/plug"
)

const (
atomicLongFlagName = "name"
atomicLongPropertyName = "atomic-long"
)

type AtomicLongCommand struct {
}
type Command struct{}

func (mc *AtomicLongCommand) Init(cc plug.InitContext) error {
func (Command) Init(cc plug.InitContext) error {
cc.SetCommandUsage("atomic-long")
cc.AddCommandGroup(clc.GroupDDSID, clc.GroupDDSTitle)
cc.SetCommandGroup(clc.GroupDDSID)
cc.AddStringFlag(atomicLongFlagName, "n", defaultAtomicLongName, false, "atomic long name")
cc.SetTopLevel(true)
cc.SetCommandUsage("atomic-long [command] [flags]")
help := "Atomic long operations"
help := "AtomicLong operations"
cc.SetCommandHelp(help, help)
cc.AddStringFlag(base.FlagName, "n", base.DefaultName, false, "AtomicLong name")
return nil
}

func (mc *AtomicLongCommand) Exec(context.Context, plug.ExecContext) error {
return nil
}

func (mc *AtomicLongCommand) Augment(ec plug.ExecContext, props *plug.Properties) error {
ctx := context.TODO()
props.SetBlocking(atomicLongPropertyName, func() (any, error) {
name := ec.Props().GetString(atomicLongFlagName)
// empty atomic long name is allowed
ci, err := ec.ClientInternal(ctx)
if err != nil {
return nil, err
}
mv, stop, err := ec.ExecuteBlocking(ctx, func(ctx context.Context, sp clc.Spinner) (any, error) {
sp.SetText(fmt.Sprintf("Getting atomic long %s", name))
m, err := ci.Client().CPSubsystem().GetAtomicLong(ctx, name)
if err != nil {
return nil, err
}
return m, nil
})
if err != nil {
return nil, err
}
stop()
return mv.(*hazelcast.AtomicLong), nil
})
func (Command) Exec(context.Context, plug.ExecContext) error {
return nil
}

func init() {
cmd := &AtomicLongCommand{}
Must(plug.Registry.RegisterCommand("atomic-long", cmd))
plug.Registry.RegisterAugmentor("20-atomic-long", cmd)
check.Must(plug.Registry.RegisterCommand("atomic-long", &Command{}))
}
15 changes: 7 additions & 8 deletions base/commands/atomic_long/atomic_long_decrement_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ package atomiclong
import (
"context"

. "github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/plug"
)

type AtomicLongDecrementGetCommand struct{}
type DecrementGetCommand struct{}

func (mc *AtomicLongDecrementGetCommand) Init(cc plug.InitContext) error {
cc.SetPositionalArgCount(0, 0)
func (DecrementGetCommand) Init(cc plug.InitContext) error {
cc.SetCommandUsage("decrement-get")
help := "Decrement the AtomicLong by the given value"
cc.AddIntFlag(atomicLongFlagBy, "", 1, false, "value to decrement by")
cc.SetCommandHelp(help, help)
cc.SetCommandUsage("decrement-get [flags]")
cc.AddIntFlag(flagBy, "", 1, false, "value to decrement by")
return nil
}

func (mc *AtomicLongDecrementGetCommand) Exec(ctx context.Context, ec plug.ExecContext) error {
func (DecrementGetCommand) Exec(ctx context.Context, ec plug.ExecContext) error {
return atomicLongChangeValue(ctx, ec, "Decrement", func(i int64) int64 { return -1 * i })
}

func init() {
Must(plug.Registry.RegisterCommand("atomic-long:decrement-get", &AtomicLongDecrementGetCommand{}))
check.Must(plug.Registry.RegisterCommand("atomic-long:decrement-get", &DecrementGetCommand{}))
}
14 changes: 14 additions & 0 deletions base/commands/atomic_long/atomic_long_destroy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//go:build std || atomiclong

package atomiclong

import (
"github.com/hazelcast/hazelcast-commandline-client/base/commands"
"github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/plug"
)

func init() {
c := commands.NewDestroyCommand("AtomicLong", getAtomicLong)
check.Must(plug.Registry.RegisterCommand("atomic-long:destroy", c))
}
46 changes: 21 additions & 25 deletions base/commands/atomic_long/atomic_long_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,50 @@ import (
"context"
"fmt"

"github.com/hazelcast/hazelcast-go-client"

"github.com/hazelcast/hazelcast-commandline-client/clc"
. "github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/clc/cmd"
"github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/output"
"github.com/hazelcast/hazelcast-commandline-client/internal/plug"
"github.com/hazelcast/hazelcast-commandline-client/internal/serialization"
)

type AtomicLongGetCommand struct{}
type GetCommand struct{}

func (mc *AtomicLongGetCommand) Init(cc plug.InitContext) error {
func (GetCommand) Init(cc plug.InitContext) error {
cc.SetCommandUsage("get")
help := "Get the value of the AtomicLong"
cc.SetCommandHelp(help, help)
cc.SetCommandUsage("get")
cc.SetPositionalArgCount(0, 0)
return nil
}

func (mc *AtomicLongGetCommand) Exec(ctx context.Context, ec plug.ExecContext) error {
al, err := ec.Props().GetBlocking(atomicLongPropertyName)
if err != nil {
return err
}
ali := al.(*hazelcast.AtomicLong)
vali, stop, err := ec.ExecuteBlocking(ctx, func(ctx context.Context, sp clc.Spinner) (any, error) {
sp.SetText(fmt.Sprintf("Setting value into AtomicLong %s", ali.Name()))
func (GetCommand) Exec(ctx context.Context, ec plug.ExecContext) error {
row, stop, err := cmd.ExecuteBlocking(ctx, ec, func(ctx context.Context, sp clc.Spinner) (output.Row, error) {
ali, err := getAtomicLong(ctx, ec, sp)
if err != nil {
return nil, err
}
sp.SetText(fmt.Sprintf("Getting value of AtomicLong %s", ali.Name()))
val, err := ali.Get(ctx)
if err != nil {
return nil, err
}
return val, nil
row := output.Row{
output.Column{
Name: "Value",
Type: serialization.TypeInt64,
Value: val,
},
}
return row, nil
})
if err != nil {
return err
}
stop()
val := vali.(int64)
row := output.Row{
output.Column{
Name: "Value",
Type: serialization.TypeInt64,
Value: val,
},
}
return ec.AddOutputRows(ctx, row)
}

func init() {
Must(plug.Registry.RegisterCommand("atomic-long:get", &AtomicLongGetCommand{}))
check.Must(plug.Registry.RegisterCommand("atomic-long:get", &GetCommand{}))
}
17 changes: 8 additions & 9 deletions base/commands/atomic_long/atomic_long_increment_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ package atomiclong
import (
"context"

. "github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/plug"
)

type AtomicLongIncrementGetCommand struct{}
type IncrementGetCommand struct{}

func (mc *AtomicLongIncrementGetCommand) Init(cc plug.InitContext) error {
cc.SetPositionalArgCount(0, 0)
help := "Increment the atomic long by the given value"
cc.AddIntFlag(atomicLongFlagBy, "", 1, false, "value to increment by")
func (mc *IncrementGetCommand) Init(cc plug.InitContext) error {
cc.SetCommandUsage("increment-get")
help := "Increment the AtomicLong by the given value"
cc.SetCommandHelp(help, help)
cc.SetCommandUsage("increment-get [flags]")
cc.AddIntFlag(flagBy, "", 1, false, "value to increment by")
return nil
}

func (mc *AtomicLongIncrementGetCommand) Exec(ctx context.Context, ec plug.ExecContext) error {
func (mc *IncrementGetCommand) Exec(ctx context.Context, ec plug.ExecContext) error {
return atomicLongChangeValue(ctx, ec, "Increment", func(i int64) int64 { return i })
}

func init() {
Must(plug.Registry.RegisterCommand("atomic-long:increment-get", &AtomicLongIncrementGetCommand{}))
check.Must(plug.Registry.RegisterCommand("atomic-long:increment-get", &IncrementGetCommand{}))
}
Loading

0 comments on commit d5a9311

Please sign in to comment.