Skip to content

Commit

Permalink
Merge pull request #31 from loikg/refactor/rebuild-cli-internals
Browse files Browse the repository at this point in the history
Refactor: rebuild internal
  • Loading branch information
loikg authored Oct 9, 2023
2 parents 651c45f + 4162278 commit bf2a3df
Show file tree
Hide file tree
Showing 40 changed files with 1,077 additions and 789 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ jobs:
runs-on: ubuntu-latest
env:
HEDERA_NODE_VERSION: 2.14.0
NETWORK: local
OPERATOR_ID: ${{ secrets.OPERATOR_ID }}
OPERATOR_KEY: ${{ secrets.OPERATOR_KEY }}
steps:
- uses: actions/checkout@v4.1.0
- name: Set up Go
uses: actions/setup-go@v4.1.0
with:
go-version: 1.21.1
- uses: actions/setup-node@v3.8.1
- name: Install Task
uses: arduino/setup-task@v1.0.3
- name: Set up Node
uses: actions/setup-node@v3.8.1
with:
cache: npm
cache-dependency-path: .github/workflows/ci.yml
node-version: 20.7.0
- name: Run go vet
run: go vet ./...
- name: Run go build
run: go build -v
- name: Start hedera-local
run: npx --yes @hashgraph/hedera-local@v$HEDERA_NODE_VERSION start --network local -d
- name: Run go test
run: go test -v ./...
- name: Stop hedera-local
if: always()
run: npx --yes @hashgraph/hedera-local@v$HEDERA_NODE_VERSION stop
run: task test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ go.work
# bin
hedera-cli
dist/

.env
26 changes: 13 additions & 13 deletions .golangci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ format = "colored-line-number"
enable = [
# Visit https://golangci-lint.run/usage/linters/
# for the full, current list of available linters.

# Default linters
"errcheck", # Detect unchecked errors
"gosimple", # Suggest code simplifications
"govet", # Reports suspicious constructs
"errcheck", # Detect unchecked errors
"gosimple", # Suggest code simplifications
"govet", # Reports suspicious constructs
"ineffassign", # Detects unused variable assignments
"staticcheck", # go vet on steroids
"typecheck", # Standard Go type checks
"unused", # Detect unused constants, variables, functions and types
"typecheck", # Standard Go type checks
"unused", # Detect unused constants, variables, functions and types

# Suggested additional linters
"gocyclo", # or "cyclop", # Detect cyclomatic complexity
"goconst", # Detect repeated values that can be made constants
"gofumpt", # Or "gofmt", # Enforce standard formatting
"gocyclo", # or "cyclop", # Detect cyclomatic complexity
"goconst", # Detect repeated values that can be made constants
"gofumpt", # Or "gofmt", # Enforce standard formatting
"goimports", # Ensure standard import formatting/ordering
"misspell", # Fix spelling errors
"revive", # General purpose linter
"misspell", # Fix spelling errors
"revive", # General purpose linter
"unconvert", # Detect unnecessary type conversions
"unparam", # Detect unused function parameters
"unparam", # Detect unused function parameters

# Optional
"bodyclose", # Check whether HTTP response bodies are closed
Expand All @@ -39,4 +39,4 @@ enable = [
]

[issues]
exclude-use-default = false
exclude-use-default = false
93 changes: 51 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,68 @@ This project is a work in progress and is not production ready. Use it at your o

hedera-cli make it easy to interact with the hedera blockchain from the command line.
It can connect to a local hedera node, testnet and mainnet.
Operators and networks can be configured in the config file located at $HOME/.hedera-cli.yaml by default.

## Install

```sh
go install github.com/loikg/hedera-cli@latest
```

## Configuration

By default hedera-cli looks for a config file in `$HOME/.hedera-cli.yaml`.
This can be overrided with the `--config` flag.

You need to configure the operator account for the networks you wich to interact with.
## Usage

```yaml
networks:
local:
operatorId: "0.0.1022"
operatorKey: "xxxx"
testnet:
operatorId: "0.0.1022"
operatorKey: "xxxx"
mainnet:
operatorId: "0.0.1022"
operatorKey: "xxxx"
```
NAME:
hedera-cli - hedera-cli make it easy to interact with the hedera blockchain
USAGE:
hedera-cli [global options] command [command options] [arguments...]
DESCRIPTION:
hedera-cli make it easy to interact with the hedera blockchain form the command line.
It can connect to a local hedera node, testnet and mainnet.
Operator and network can be configured inYou can either provide the
--network, --operator-id, --operator-key or use the HEDERA_NETWORK, HEDERA_OPERATOR_ID,
HEDERA_OPERATOR_KEY environment variables.
COMMANDS:
account, a Manage hedera accounts
keygen, kg Create a private key.
token, t Create, update, delete fungible and non fungible tokens
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--network value Hedera network to connect to, possible values are local,testnet,mainnet [$HEDERA_NETWORK, $NETWORK]
--operator-id value Hedera operator account id [$HEDERA_OPERATOR_ID, $OPERATOR_ID]
--operator-key value Hedera operator account private key [$HEDERA_OPERATOR_KEY, $OPERATOR_KEY]
--help, -h show help
```

By default hedera-cli will use the `local` network unless you specify a network with `--network`.
## Examples

## Usage
### Create an account

```shell
export HEDERA_NETWORK=local
export HEDERA_OPERATOR_ID=0.0.1022
export HEDERA_OPERATOR_KEY=a608e2130a0a3cb34f86e757303c862bee353d9ab77ba4387ec084f881d420d4

hedera-cli account create
```
hedera-cli make it easy to interact with the hedera blockchain form the command line.
It can connect to a local hedera node, testnet and mainnet.
Operator and network can be configured in the config file located at $HOME/.hedera-cli.yaml by default.

Usage:
hedera-cli [command]

Available Commands:
account Create, update, delete accounts
completion Generate the autocompletion script for the specified shell
help Help about any command
keygen Create a private key.
token Create, update, delete fungible and non fungible tokens
version Display version

Flags:
--config string config file (default is $HOME/.hedera-cli.yaml)
-h, --help help for hedera-cli
--network string Network to connect to either local,testnet or mainnet
--verbose enable debug mesage useful for debugging

Use "hedera-cli [command] --help" for more information about a command.

### Create a fungible token

```shell
export HEDERA_NETWORK=local
export HEDERA_OPERATOR_ID=0.0.1022
export HEDERA_OPERATOR_KEY=a608e2130a0a3cb34f86e757303c862bee353d9ab77ba4387ec084f881d420d4

hedera-cli token create \
--balance 100 \
--decimals 2 \
--name myToken \
--symbol MTK \
--type ft \
--supply-type infinite \
--treasury-id 0.0.1022 \
--treasury-key $HEDERA_OPERATOR_KEY
```
28 changes: 28 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: "3"
vars:
HEDERA_LOCAL_VERSION: v2.14.0

dotenv: [".env"]

tasks:
build:
cmds:
- go build

lint:
cmds:
- golangci-lint run ./...

"hedera:start":
cmds:
- npx --yes @hashgraph/hedera-local@{{ .HEDERA_LOCAL_VERSION }} start -d --network local

"hedera:stop":
cmds:
- npx --yes @hashgraph/hedera-local@{{ .HEDERA_LOCAL_VERSION }} stop

test:
deps: [build, "hedera:start"]
cmds:
- defer: { task: "hedera:stop" }
- go test -v ./...
4 changes: 0 additions & 4 deletions cmd/.hedera-cli

This file was deleted.

19 changes: 0 additions & 19 deletions cmd/account.go

This file was deleted.

55 changes: 0 additions & 55 deletions cmd/account_balance.go

This file was deleted.

18 changes: 0 additions & 18 deletions cmd/account_balance_test.go

This file was deleted.

49 changes: 0 additions & 49 deletions cmd/account_create.go

This file was deleted.

Loading

0 comments on commit bf2a3df

Please sign in to comment.