Skip to content

Commit

Permalink
fix: use keyscli module to be able to share package code with test in…
Browse files Browse the repository at this point in the history
…tegration

Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
  • Loading branch information
gfanton committed Dec 22, 2023
1 parent f7aa61f commit ddbddd2
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion gno.land/cmd/gnokey/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"

"github.com/gnolang/gno/gno.land/pkg/keyscli"
"github.com/gnolang/gno/gnovm/pkg/gnoenv"
"github.com/gnolang/gno/tm2/pkg/commands"
"github.com/gnolang/gno/tm2/pkg/crypto/keys/client"
Expand All @@ -16,7 +17,7 @@ func main() {
Remote: "127.0.0.1:26657",
}

cmd := NewRoot(commands.NewDefaultIO(), baseCfg)
cmd := keyscli.NewRootCmd(commands.NewDefaultIO(), baseCfg)

Check warning on line 20 in gno.land/cmd/gnokey/main.go

View check run for this annotation

Codecov / codecov/patch

gno.land/cmd/gnokey/main.go#L20

Added line #L20 was not covered by tests
if err := cmd.ParseAndRun(context.Background(), os.Args[1:]); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "%+v\n", err)

Expand Down
3 changes: 2 additions & 1 deletion gno.land/pkg/integration/testing_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"
"testing"

"github.com/gnolang/gno/gno.land/pkg/keyscli"
"github.com/gnolang/gno/gnovm/pkg/gnoenv"
"github.com/gnolang/gno/tm2/pkg/bft/node"
"github.com/gnolang/gno/tm2/pkg/commands"
Expand Down Expand Up @@ -181,7 +182,7 @@ func setupGnolandTestScript(t *testing.T, txtarDir string) testscript.Params {
io := commands.NewTestIO()
io.SetOut(commands.WriteNopCloser(ts.Stdout()))
io.SetErr(commands.WriteNopCloser(ts.Stderr()))
cmd := client.NewRootCmd(io)
cmd := keyscli.NewRootCmd(io, client.DefaultBaseOptions)

io.SetIn(strings.NewReader("\n")) // Inject empty password to stdin.
defaultArgs := []string{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package keyscli

// TODO: move most of the logic in ROOT/gno.land/...

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package keyscli

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package keyscli

import (
"flag"
Expand Down
6 changes: 3 additions & 3 deletions gno.land/cmd/gnokey/root.go → gno.land/pkg/keyscli/root.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Dedicated to my love, Lexi.
package main
package keyscli

import (
"github.com/gnolang/gno/tm2/pkg/commands"
Expand All @@ -9,7 +9,7 @@ import (
"github.com/peterbourgon/ff/v3/fftoml"
)

func NewRoot(io commands.IO, base client.BaseOptions) *commands.Command {
func NewRootCmd(io commands.IO, base client.BaseOptions) *commands.Command {
cfg := &client.BaseCfg{
BaseOptions: base,
}
Expand Down Expand Up @@ -39,7 +39,7 @@ func NewRoot(io commands.IO, base client.BaseOptions) *commands.Command {
client.NewQueryCmd(cfg, io),
client.NewBroadcastCmd(cfg, io),

// Use custom MakeTX command
// Custom MakeTX command
NewMakeTxCmd(cfg, io),
)

Expand Down
2 changes: 1 addition & 1 deletion gno.land/cmd/gnokey/run.go → gno.land/pkg/keyscli/run.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package keyscli

import (
"context"
Expand Down

0 comments on commit ddbddd2

Please sign in to comment.