forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move all subcommands out of main into proper folders
- Loading branch information
1 parent
7779eec
commit bae7cec
Showing
6 changed files
with
108 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package lcd | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
) | ||
|
||
const ( | ||
flagBind = "bind" | ||
flagCORS = "cors" | ||
) | ||
|
||
// XXX: remove this when not needed | ||
func todoNotImplemented(_ *cobra.Command, _ []string) error { | ||
return errors.New("TODO: Command not yet implemented") | ||
} | ||
|
||
// ServeCommand will generate a long-running rest server | ||
// (aka Light Client Daemon) that exposes functionality similar | ||
// to the cli, but over rest | ||
func ServeCommand() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "serve", | ||
Short: "Start LCD (light-client daemon), a local REST server", | ||
RunE: todoNotImplemented, | ||
} | ||
// TODO: handle unix sockets also? | ||
cmd.Flags().StringP(flagBind, "b", "localhost:1317", "Interface and port that server binds to") | ||
cmd.Flags().String(flagCORS, "", "Set to domains that can make CORS requests (* for all)") | ||
cmd.Flags().StringP(client.FlagChainID, "c", "", "ID of chain we connect to") | ||
cmd.Flags().StringP(client.FlagNode, "n", "tcp://localhost:46657", "Node to connect to") | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package tx | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
const ( | ||
flagTags = "tag" | ||
flagAny = "any" | ||
) | ||
|
||
// XXX: remove this when not needed | ||
func todoNotImplemented(_ *cobra.Command, _ []string) error { | ||
return errors.New("TODO: Command not yet implemented") | ||
} | ||
|
||
// AddCommands adds a number of tx-query related subcommands | ||
func AddCommands(cmd *cobra.Command) { | ||
cmd.AddCommand( | ||
txSearchCommand(), | ||
txCommand(), | ||
) | ||
} | ||
|
||
func txSearchCommand() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "txs", | ||
Short: "Search for all transactions that match the given tags", | ||
RunE: todoNotImplemented, | ||
} | ||
cmd.Flags().StringSlice(flagTags, nil, "Tags that must match (may provide multiple)") | ||
cmd.Flags().Bool(flagAny, false, "Return transactions that match ANY tag, rather than ALL") | ||
return cmd | ||
} | ||
|
||
func txCommand() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "tx <hash>", | ||
Short: "Matches this txhash over all committed blocks", | ||
RunE: todoNotImplemented, | ||
} | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters