Skip to content

Commit 4e029f2

Browse files
committed
move env to separate env file
1 parent bf2f946 commit 4e029f2

17 files changed

Lines changed: 596 additions & 123 deletions

CLI.md

Lines changed: 167 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ See:
2323
2424
2525
COMMAND GROUPS:
26-
{contract,tx,validator,ledger,wallet,validator-wallet,deps,config,localnet,data,staking-provider,dns,faucet}
26+
{contract,tx,validator,ledger,wallet,validator-wallet,deps,config,localnet,data,staking-provider,dns,faucet,env}
2727
2828
TOP-LEVEL OPTIONS:
2929
-h, --help show this help message and exit
@@ -40,12 +40,13 @@ ledger Get Ledger App addresses and version
4040
wallet Create wallet, derive secret key from mnemonic, bech32 address helpers etc.
4141
validator-wallet Create a validator wallet, sign and verify messages and convert a validator wallet to a hex secret key.
4242
deps Manage dependencies or multiversx-sdk modules
43-
config Configure multiversx-sdk (default values etc.)
43+
config Configure MultiversX CLI (default values etc.)
4444
localnet Set up, start and control localnets
4545
data Data manipulation omnitool
4646
staking-provider Staking provider omnitool
4747
dns Operations related to the Domain Name Service
4848
faucet Get xEGLD on Devnet or Testnet
49+
env Configure MultiversX CLI to use specific environment values.
4950
5051
```
5152
## Group **Contract**
@@ -421,6 +422,7 @@ options:
421422
or Ledger devices (default: 0)
422423
--sender-username SENDER_USERNAME 🖄 the username of the sender
423424
--hrp HRP The hrp used to convert the address to its bech32 representation
425+
--skip-confirmation, -y can be used to skip the confirmation prompt
424426
425427
```
426428
### Contract.ReproducibleBuild
@@ -2830,7 +2832,7 @@ options:
28302832
$ mxpy config --help
28312833
usage: mxpy config COMMAND [-h] ...
28322834
2833-
Configure multiversx-sdk (default values etc.)
2835+
Configure MultiversX CLI (default values etc.)
28342836
28352837
COMMANDS:
28362838
{dump,get,set,delete,new,switch,list,reset}
@@ -2841,12 +2843,12 @@ OPTIONS:
28412843
----------------
28422844
COMMANDS summary
28432845
----------------
2844-
dump Dumps configuration.
2845-
get Gets a configuration value.
2846-
set Sets a configuration value.
2847-
delete Deletes a configuration value.
2848-
new Creates a new configuration.
2849-
switch Switch to a different config
2846+
dump Dumps the active configuration.
2847+
get Gets a configuration value from the active configuration.
2848+
set Sets a configuration value for the active configuration.
2849+
delete Deletes a configuration value from the active configuration.
2850+
new Creates a new configuration and sets it as the active configuration.
2851+
switch Switch to a different config.
28502852
list List available configs
28512853
reset Deletes the config file. Default config will be used.
28522854
@@ -2858,7 +2860,7 @@ reset Deletes the config file. Default config will be u
28582860
$ mxpy config dump --help
28592861
usage: mxpy config dump [-h] ...
28602862
2861-
Dumps configuration.
2863+
Dumps the active configuration.
28622864
28632865
options:
28642866
-h, --help show this help message and exit
@@ -2872,7 +2874,7 @@ options:
28722874
$ mxpy config get --help
28732875
usage: mxpy config get [-h] ...
28742876
2875-
Gets a configuration value.
2877+
Gets a configuration value from the active configuration.
28762878
28772879
positional arguments:
28782880
name the name of the configuration entry
@@ -2888,7 +2890,7 @@ options:
28882890
$ mxpy config set --help
28892891
usage: mxpy config set [-h] ...
28902892
2891-
Sets a configuration value.
2893+
Sets a configuration value for the active configuration.
28922894
28932895
positional arguments:
28942896
name the name of the configuration entry
@@ -2905,7 +2907,7 @@ options:
29052907
$ mxpy config new --help
29062908
usage: mxpy config new [-h] ...
29072909
2908-
Creates a new configuration.
2910+
Creates a new configuration and sets it as the active configuration.
29092911
29102912
positional arguments:
29112913
name the name of the configuration entry
@@ -2922,7 +2924,7 @@ options:
29222924
$ mxpy config switch --help
29232925
usage: mxpy config switch [-h] ...
29242926
2925-
Switch to a different config
2927+
Switch to a different config.
29262928
29272929
positional arguments:
29282930
name the name of the configuration entry
@@ -3074,3 +3076,154 @@ options:
30743076
--wallet-url WALLET_URL custom wallet url to call the faucet from
30753077
30763078
```
3079+
## Group **Environment**
3080+
3081+
3082+
```
3083+
$ mxpy env --help
3084+
usage: mxpy env COMMAND [-h] ...
3085+
3086+
Configure MultiversX CLI to use specific environment values.
3087+
3088+
COMMANDS:
3089+
{new,get,set,dump,delete,switch,list,remove,reset}
3090+
3091+
OPTIONS:
3092+
-h, --help show this help message and exit
3093+
3094+
----------------
3095+
COMMANDS summary
3096+
----------------
3097+
new Creates a new environment and sets it as the active environment.
3098+
get Gets an env value from the active environment.
3099+
set Sets an env value for the active environment.
3100+
dump Dumps the active environment.
3101+
delete Deletes an env value from the active environment.
3102+
switch Switch to a different environment.
3103+
list List available environments
3104+
remove Deletes an environment from the env file. Will switch to default env.
3105+
reset Deletes the environment file. Default env will be used.
3106+
3107+
```
3108+
### Environment.New
3109+
3110+
3111+
```
3112+
$ mxpy env new --help
3113+
usage: mxpy env new [-h] ...
3114+
3115+
Creates a new environment and sets it as the active environment.
3116+
3117+
positional arguments:
3118+
name the name of the configuration entry
3119+
3120+
options:
3121+
-h, --help show this help message and exit
3122+
--template TEMPLATE an environment from which to create the new environment
3123+
3124+
```
3125+
### Environment.Set
3126+
3127+
3128+
```
3129+
$ mxpy env set --help
3130+
usage: mxpy env set [-h] ...
3131+
3132+
Sets an env value for the active environment.
3133+
3134+
positional arguments:
3135+
name the name of the configuration entry
3136+
value the new value
3137+
3138+
options:
3139+
-h, --help show this help message and exit
3140+
3141+
```
3142+
### Environment.Get
3143+
3144+
3145+
```
3146+
$ mxpy env get --help
3147+
usage: mxpy env get [-h] ...
3148+
3149+
Gets an env value from the active environment.
3150+
3151+
positional arguments:
3152+
name the name of the configuration entry
3153+
3154+
options:
3155+
-h, --help show this help message and exit
3156+
3157+
```
3158+
### Environment.Dump
3159+
3160+
3161+
```
3162+
$ mxpy env dump --help
3163+
usage: mxpy env dump [-h] ...
3164+
3165+
Dumps the active environment.
3166+
3167+
options:
3168+
-h, --help show this help message and exit
3169+
--default dumps the default environment instead of the active one.
3170+
3171+
```
3172+
### Environment.Switch
3173+
3174+
3175+
```
3176+
$ mxpy env switch --help
3177+
usage: mxpy env switch [-h] ...
3178+
3179+
Switch to a different environment.
3180+
3181+
positional arguments:
3182+
name the name of the configuration entry
3183+
3184+
options:
3185+
-h, --help show this help message and exit
3186+
3187+
```
3188+
### Environment.List
3189+
3190+
3191+
```
3192+
$ mxpy env list --help
3193+
usage: mxpy env list [-h] ...
3194+
3195+
List available environments
3196+
3197+
options:
3198+
-h, --help show this help message and exit
3199+
3200+
```
3201+
### Environment.Remove
3202+
3203+
3204+
```
3205+
$ mxpy env remove --help
3206+
usage: mxpy env remove [-h] ...
3207+
3208+
Deletes an environment from the env file. Will switch to default env.
3209+
3210+
positional arguments:
3211+
environment The environment to remove from env file.
3212+
3213+
options:
3214+
-h, --help show this help message and exit
3215+
3216+
```
3217+
### Environment.Reset
3218+
3219+
3220+
```
3221+
$ mxpy env reset --help
3222+
usage: mxpy env reset [-h] ...
3223+
3224+
Deletes the environment file. Default env will be used.
3225+
3226+
options:
3227+
-h, --help show this help message and exit
3228+
3229+
```

CLI.md.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ generate() {
130130

131131
group "Faucet" "faucet"
132132
command "Faucet.Request" "faucet request"
133+
134+
group "Environment" "env"
135+
command "Environment.New" "env new"
136+
command "Environment.Set" "env set"
137+
command "Environment.Get" "env get"
138+
command "Environment.Dump" "env dump"
139+
command "Environment.Switch" "env switch"
140+
command "Environment.List" "env list"
141+
command "Environment.Remove" "env remove"
142+
command "Environment.Reset" "env reset"
133143
}
134144

135145
generate

multiversx_sdk_cli/cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import multiversx_sdk_cli.cli_delegation
1616
import multiversx_sdk_cli.cli_deps
1717
import multiversx_sdk_cli.cli_dns
18+
import multiversx_sdk_cli.cli_env
1819
import multiversx_sdk_cli.cli_faucet
1920
import multiversx_sdk_cli.cli_ledger
2021
import multiversx_sdk_cli.cli_localnet
@@ -24,6 +25,7 @@
2425
import multiversx_sdk_cli.cli_wallet
2526
import multiversx_sdk_cli.version
2627
from multiversx_sdk_cli import config, errors, utils, ux
28+
from multiversx_sdk_cli.env import get_address_hrp
2729

2830
logger = logging.getLogger("cli")
2931

@@ -64,7 +66,7 @@ def _do_main(cli_args: list[str]):
6466
)
6567

6668
verify_deprecated_entries_in_config_file()
67-
default_hrp = config.get_address_hrp()
69+
default_hrp = get_address_hrp()
6870
LibraryConfig.default_address_hrp = default_hrp
6971

7072
if hasattr(args, "recall_nonce") and args.recall_nonce:
@@ -123,6 +125,7 @@ def setup_parser(args: list[str]):
123125
commands.append(multiversx_sdk_cli.cli_delegation.setup_parser(args, subparsers))
124126
commands.append(multiversx_sdk_cli.cli_dns.setup_parser(args, subparsers))
125127
commands.append(multiversx_sdk_cli.cli_faucet.setup_parser(args, subparsers))
128+
commands.append(multiversx_sdk_cli.cli_env.setup_parser(subparsers))
126129

127130
parser.epilog = """
128131
----------------------

multiversx_sdk_cli/cli_contracts.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
validate_transaction_args,
2626
)
2727
from multiversx_sdk_cli.cli_output import CLIOutputBuilder
28-
from multiversx_sdk_cli.config import MxpyConfig, get_config_for_network_providers
28+
from multiversx_sdk_cli.config import get_config_for_network_providers
2929
from multiversx_sdk_cli.constants import NUMBER_OF_SHARDS
3030
from multiversx_sdk_cli.contract_verification import trigger_contract_verification
3131
from multiversx_sdk_cli.contracts import SmartContract
3232
from multiversx_sdk_cli.docker import is_docker_installed, run_docker
33+
from multiversx_sdk_cli.env import MxpyEnv
3334
from multiversx_sdk_cli.errors import DockerMissingError
3435
from multiversx_sdk_cli.ux import show_warning
3536

@@ -376,7 +377,7 @@ def build(args: Any):
376377
def deploy(args: Any):
377378
logger.debug("deploy")
378379

379-
cli_config = MxpyConfig.from_active_config()
380+
cli_config = MxpyEnv.from_active_env()
380381
cli_shared.set_proxy_from_config_if_not_provided(args, cli_config)
381382

382383
validate_transaction_args(args)
@@ -428,7 +429,7 @@ def deploy(args: Any):
428429
def call(args: Any):
429430
logger.debug("call")
430431

431-
cli_config = MxpyConfig.from_active_config()
432+
cli_config = MxpyEnv.from_active_env()
432433
cli_shared.set_proxy_from_config_if_not_provided(args, cli_config)
433434

434435
validate_transaction_args(args)
@@ -473,7 +474,7 @@ def call(args: Any):
473474
def upgrade(args: Any):
474475
logger.debug("upgrade")
475476

476-
cli_config = MxpyConfig.from_active_config()
477+
cli_config = MxpyEnv.from_active_env()
477478
cli_shared.set_proxy_from_config_if_not_provided(args, cli_config)
478479

479480
validate_transaction_args(args)
@@ -521,7 +522,7 @@ def upgrade(args: Any):
521522
def query(args: Any):
522523
logger.debug("query")
523524

524-
cli_config = MxpyConfig.from_active_config()
525+
cli_config = MxpyEnv.from_active_env()
525526
cli_shared.set_proxy_from_config_if_not_provided(args, cli_config)
526527

527528
validate_proxy_argument(args)

0 commit comments

Comments
 (0)