From 8e252bc6e44adecf5b153f5b4d629e70aeb6a8fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=C3=B4ng=20Li=E1=BB=81u?= <93205232+DongLieu@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:42:00 +0700 Subject: [PATCH] list-env CLI command (#6709) * cli for all Environment * changelog * Update cmd/osmosisd/cmd/change_environment.go Co-authored-by: Matt, Park <45252226+mattverse@users.noreply.github.com> * lint --------- Co-authored-by: Matt, Park <45252226+mattverse@users.noreply.github.com> --- CHANGELOG.md | 1 + cmd/osmosisd/cmd/change_environment.go | 47 ++++++++++++++++++++++++++ cmd/osmosisd/cmd/root.go | 1 + 3 files changed, 49 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 185abecaf7c..1ce58ff8295 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#6420](https://github.com/osmosis-labs/osmosis/pull/6420) feat[CL]: Creates a governance set whitelist of addresses that can bypass the normal pool creation restrictions on concentrated liquidity pools * [#6623](https://github.com/osmosis-labs/osmosis/pull/6420) feat: transfer cl positions to new owner * [#6632](https://github.com/osmosis-labs/osmosis/pull/6632) Taker fee bypass whitelist +* [#6709](https://github.com/osmosis-labs/osmosis/pull/6709) CLI: Add list-env, all Environment for CLI ### State Breaking diff --git a/cmd/osmosisd/cmd/change_environment.go b/cmd/osmosisd/cmd/change_environment.go index b6609dc147a..6ec7afce7f4 100644 --- a/cmd/osmosisd/cmd/change_environment.go +++ b/cmd/osmosisd/cmd/change_environment.go @@ -226,3 +226,50 @@ func customArgs(cmd *cobra.Command, args []string) error { } return nil } +func PrintAllEnvironmentCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-env ", + Short: "listing all available environments.", + Long: `listing all available environments. +Example: + osmosisd list-env' + Returns all EnvironmentCmd`, + RunE: func(cmd *cobra.Command, args []string) error { + // mainnet + path, err := environmentNameToPath(EnvMainnet) + if err != nil { + fmt.Printf("Error: %v \n", err) + } + + fmt.Printf("Environment name, path: %s, %s\n", EnvMainnet, path) + + // localnet + path, err = environmentNameToPath(EnvLocalnet) + if err != nil { + fmt.Printf("Error: %v \n", err) + } + + fmt.Printf("Environment name, path: %s, %s\n", EnvLocalnet, path) + + // testnet + path, err = environmentNameToPath(EnvTestnet) + if err != nil { + fmt.Printf("Error: %v \n", err) + } + + fmt.Printf("Environment name, path: %s, %s\n", EnvTestnet, path) + + // OSMOSISD_ENVIRONMENT + val := os.Getenv(EnvVariable) + path, err = environmentNameToPath(val) + if err != nil { + fmt.Printf("Error: %v \n", err) + } + + fmt.Printf("Environment name, path: %s, %s\n", EnvVariable, path) + + return nil + }, + } + return cmd +} diff --git a/cmd/osmosisd/cmd/root.go b/cmd/osmosisd/cmd/root.go index 506a83d6a4e..a68d6aab9f4 100644 --- a/cmd/osmosisd/cmd/root.go +++ b/cmd/osmosisd/cmd/root.go @@ -487,6 +487,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { ConfigCmd(), ChangeEnvironmentCmd(), PrintEnvironmentCmd(), + PrintAllEnvironmentCmd(), UpdateAssetListCmd(osmosis.DefaultNodeHome, osmosis.ModuleBasics), )