From dfdcbd184d7679cb32dfefe7be4ce2ffd6159d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Mon, 28 Sep 2020 12:35:01 +0100 Subject: [PATCH] add --repo flag. --- cmd/tvx/extract.go | 3 ++- cmd/tvx/main.go | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/cmd/tvx/extract.go b/cmd/tvx/extract.go index d8053e5c2..3408cea12 100644 --- a/cmd/tvx/extract.go +++ b/cmd/tvx/extract.go @@ -36,9 +36,10 @@ var extractFlags struct { var extractCmd = &cli.Command{ Name: "extract", - Description: "generate a message-class test vector by extracting it from a live chain", + Description: "generate a test vector by extracting it from a live chain", Action: runExtract, Flags: []cli.Flag{ + &repoFlag, &cli.StringFlag{ Name: "class", Usage: "class of vector to extract; other required flags depend on the; values: 'message'", diff --git a/cmd/tvx/main.go b/cmd/tvx/main.go index a74a029ce..361ba41c3 100644 --- a/cmd/tvx/main.go +++ b/cmd/tvx/main.go @@ -8,6 +8,18 @@ import ( "github.com/urfave/cli/v2" ) +// DefaultLotusRepoPath is where the fallback path where to look for a Lotus +// client repo. It is expanded with mitchellh/go-homedir, so it'll work with all +// OSes despite the Unix twiddle notation. +const DefaultLotusRepoPath = "~/.lotus" + +var repoFlag = cli.StringFlag{ + Name: "repo", + EnvVars: []string{"LOTUS_PATH"}, + Value: DefaultLotusRepoPath, + TakesFile: true, +} + func main() { app := &cli.App{ Name: "tvx", @@ -22,7 +34,7 @@ func main() { SETTING THE JSON-RPC API ENDPOINT - You can set the JSON-RPC API endpoint through one of the following approaches. + You can set the JSON-RPC API endpoint through one of the following methods. 1. Directly set the API endpoint on the FULLNODE_API_INFO env variable. The format is [token]:multiaddr, where token is optional for commands not @@ -30,11 +42,12 @@ func main() { 2. If you're running tvx against a local Lotus client, you can set the REPO env variable to have the API endpoint and token extracted from the repo. + Alternatively, you can pass the --repo CLI flag. 3. Rely on the default fallback, which inspects ~/.lotus and extracts the API endpoint string if the location is a Lotus repo. - tvx will apply these approaches in the same order of precedence they're listed. + tvx will apply these methods in the same order of precedence they're listed. `, Usage: "tvx is a tool for extracting and executing test vectors", Commands: []*cli.Command{