Skip to content

Commit

Permalink
Revise usage and CLI docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Bourget committed Jun 3, 2022
1 parent 9f7418d commit fb9c955
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 75 deletions.
33 changes: 33 additions & 0 deletions cmd/substreams/graph.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
"fmt"

"github.com/spf13/cobra"
"github.com/streamingfast/substreams/manifest"
)

var graphCmd = &cobra.Command{
Use: "graph <manifest_file>",
Short: "Generate mermaid-js graph document",
RunE: runManifestGraph,
Args: cobra.ExactArgs(1),
SilenceUsage: true,
}

func init() {
rootCmd.AddCommand(graphCmd)
}

func runManifestGraph(cmd *cobra.Command, args []string) error {
manifestPath := args[0]
manifestReader := manifest.NewReader(manifestPath)
pkg, err := manifestReader.Read()
if err != nil {
return fmt.Errorf("read manifest %q: %w", manifestPath, err)
}

manifest.PrintMermaid(pkg.Modules)

return nil
}
3 changes: 2 additions & 1 deletion cmd/substreams/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
)

var inspectCmd = &cobra.Command{
Use: "inspect <manifest_yaml>",
Use: "inspect <package>",
Short: "Display low-level package structure",
RunE: runInspect,
Args: cobra.ExactArgs(1),
SilenceUsage: true,
Expand Down
30 changes: 5 additions & 25 deletions cmd/substreams/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,19 @@ import (
// Use: "manifest",
// SilenceUsage: true,
// }
var manifestInfoCmd = &cobra.Command{
var infoCmd = &cobra.Command{
Use: "info <manifest_file>",
RunE: runManifestInfo,
Args: cobra.ExactArgs(1),
SilenceUsage: true,
}

var manifestGraphCmd = &cobra.Command{
Use: "graph <manifest_file>",
RunE: runManifestGraph,
Short: "Display package modules and docs",
RunE: runInfo,
Args: cobra.ExactArgs(1),
SilenceUsage: true,
}

func init() {
rootCmd.AddCommand(manifestInfoCmd)
rootCmd.AddCommand(manifestGraphCmd)
rootCmd.AddCommand(infoCmd)
}

func runManifestInfo(cmd *cobra.Command, args []string) error {
func runInfo(cmd *cobra.Command, args []string) error {
manifestPath := args[0]
manifestReader := manifest.NewReader(manifestPath)
pkg, err := manifestReader.Read()
Expand Down Expand Up @@ -78,16 +71,3 @@ func runManifestInfo(cmd *cobra.Command, args []string) error {

return nil
}

func runManifestGraph(cmd *cobra.Command, args []string) error {
manifestPath := args[0]
manifestReader := manifest.NewReader(manifestPath)
pkg, err := manifestReader.Read()
if err != nil {
return fmt.Errorf("read manifest %q: %w", manifestPath, err)
}

manifest.PrintMermaid(pkg.Modules)

return nil
}
3 changes: 2 additions & 1 deletion cmd/substreams/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (
)

var packCmd = &cobra.Command{
Use: "pack <manifest_yaml>",
Use: "pack <package>",
Short: "Build an .spkg out of a .yaml manifest",
RunE: runPack,
Args: cobra.ExactArgs(1),
SilenceUsage: true,
Expand Down
45 changes: 0 additions & 45 deletions cmd/substreams/parallelize.go

This file was deleted.

3 changes: 2 additions & 1 deletion cmd/substreams/protogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import (
)

var protogenCmd = &cobra.Command{
Use: "protogen <manifest_yaml>",
Use: "protogen <package>",
Short: "Generate Rust bindings from a package",
RunE: runProtogen,
Args: cobra.ExactArgs(1),
SilenceUsage: true,
Expand Down
1 change: 1 addition & 0 deletions cmd/substreams/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
var rootCmd = &cobra.Command{
Use: "substreams",
Short: "A tool to manipulate Substreams, and process them locally and remotely",
Long: "Any place where <package> is specified, a 'substreams.yaml', a local '.spkg' file or an https://...spkg file can be specified",
SilenceUsage: true,
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/substreams/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func init() {
// runCmd represents the command to run substreams remotely
var runCmd = &cobra.Command{
Use: "run <manifest> <module_name>",
Short: "Run substreams remotely",
Short: "Stream modules from a given package on a remote endpoint",
RunE: runRun,
Args: cobra.ExactArgs(2),
SilenceUsage: true,
Expand Down
3 changes: 2 additions & 1 deletion cmd/substreams/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (
"os"

"github.com/spf13/cobra"
"github.com/streamingfast/substreams/tools"
)

func init() {
stateCmd.Flags().String("state-store-url", "./localdata", "URL of state store")

rootCmd.AddCommand(stateCmd)
tools.Cmd.AddCommand(stateCmd)
}

// localCmd represents the base command when called without any subcommands
Expand Down

0 comments on commit fb9c955

Please sign in to comment.