Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ venv.bak/
typings

multiversx_sdk_cli/tests/testdata-out

.DS_store
181 changes: 167 additions & 14 deletions CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ See:


COMMAND GROUPS:
{contract,tx,validator,ledger,wallet,validator-wallet,deps,config,localnet,data,staking-provider,dns,faucet,multisig,governance}
{contract,tx,validator,ledger,wallet,validator-wallet,deps,config,localnet,data,staking-provider,dns,faucet,multisig,governance,env}

TOP-LEVEL OPTIONS:
-h, --help show this help message and exit
Expand All @@ -40,14 +40,15 @@ ledger Get Ledger App addresses and version
wallet Create wallet, derive secret key from mnemonic, bech32 address helpers etc.
validator-wallet Create a validator wallet, sign and verify messages and convert a validator wallet to a hex secret key.
deps Manage dependencies or multiversx-sdk modules
config Configure multiversx-sdk (default values etc.)
config Configure MultiversX CLI (default values etc.)
localnet Set up, start and control localnets
data Data manipulation omnitool
staking-provider Staking provider omnitool
dns Operations related to the Domain Name Service
faucet Get xEGLD on Devnet or Testnet
multisig Deploy and interact with the Multisig Smart Contract
governance Propose, vote and interact with the governance contract.
env Configure MultiversX CLI to use specific environment values.

```
## Group **Contract**
Expand Down Expand Up @@ -423,6 +424,7 @@ options:
or Ledger devices (default: 0)
--sender-username SENDER_USERNAME 🖄 the username of the sender
--hrp HRP The hrp used to convert the address to its bech32 representation
--skip-confirmation, -y can be used to skip the confirmation prompt

```
### Contract.ReproducibleBuild
Expand Down Expand Up @@ -2832,7 +2834,7 @@ options:
$ mxpy config --help
usage: mxpy config COMMAND [-h] ...

Configure multiversx-sdk (default values etc.)
Configure MultiversX CLI (default values etc.)

COMMANDS:
{dump,get,set,delete,new,switch,list,reset}
Expand All @@ -2843,12 +2845,12 @@ OPTIONS:
----------------
COMMANDS summary
----------------
dump Dumps configuration.
get Gets a configuration value.
set Sets a configuration value.
delete Deletes a configuration value.
new Creates a new configuration.
switch Switch to a different config
dump Dumps the active configuration.
get Gets a configuration value from the active configuration.
set Sets a configuration value for the active configuration.
delete Deletes a configuration value from the active configuration.
new Creates a new configuration and sets it as the active configuration.
switch Switch to a different config.
list List available configs
reset Deletes the config file. Default config will be used.

Expand All @@ -2860,7 +2862,7 @@ reset Deletes the config file. Default config will be u
$ mxpy config dump --help
usage: mxpy config dump [-h] ...

Dumps configuration.
Dumps the active configuration.

options:
-h, --help show this help message and exit
Expand All @@ -2874,7 +2876,7 @@ options:
$ mxpy config get --help
usage: mxpy config get [-h] ...

Gets a configuration value.
Gets a configuration value from the active configuration.

positional arguments:
name the name of the configuration entry
Expand All @@ -2890,7 +2892,7 @@ options:
$ mxpy config set --help
usage: mxpy config set [-h] ...

Sets a configuration value.
Sets a configuration value for the active configuration.

positional arguments:
name the name of the configuration entry
Expand All @@ -2907,7 +2909,7 @@ options:
$ mxpy config new --help
usage: mxpy config new [-h] ...

Creates a new configuration.
Creates a new configuration and sets it as the active configuration.

positional arguments:
name the name of the configuration entry
Expand All @@ -2924,7 +2926,7 @@ options:
$ mxpy config switch --help
usage: mxpy config switch [-h] ...

Switch to a different config
Switch to a different config.

positional arguments:
name the name of the configuration entry
Expand Down Expand Up @@ -5893,3 +5895,154 @@ options:
--proxy PROXY 🔗 the URL of the proxy

```
## Group **Environment**


```
$ mxpy env --help
usage: mxpy env COMMAND [-h] ...

Configure MultiversX CLI to use specific environment values.

COMMANDS:
{new,get,set,dump,delete,switch,list,remove,reset}

OPTIONS:
-h, --help show this help message and exit

----------------
COMMANDS summary
----------------
new Creates a new environment and sets it as the active environment.
get Gets an env value from the active environment.
set Sets an env value for the active environment.
dump Dumps the active environment.
delete Deletes an env value from the active environment.
switch Switch to a different environment.
list List available environments
remove Deletes an environment from the env file. Will switch to default env.
reset Deletes the environment file. Default env will be used.

```
### Environment.New


```
$ mxpy env new --help
usage: mxpy env new [-h] ...

Creates a new environment and sets it as the active environment.

positional arguments:
name the name of the configuration entry

options:
-h, --help show this help message and exit
--template TEMPLATE an environment from which to create the new environment

```
### Environment.Set


```
$ mxpy env set --help
usage: mxpy env set [-h] ...

Sets an env value for the active environment.

positional arguments:
name the name of the configuration entry
value the new value

options:
-h, --help show this help message and exit

```
### Environment.Get


```
$ mxpy env get --help
usage: mxpy env get [-h] ...

Gets an env value from the active environment.

positional arguments:
name the name of the configuration entry

options:
-h, --help show this help message and exit

```
### Environment.Dump


```
$ mxpy env dump --help
usage: mxpy env dump [-h] ...

Dumps the active environment.

options:
-h, --help show this help message and exit
--default dumps the default environment instead of the active one.

```
### Environment.Switch


```
$ mxpy env switch --help
usage: mxpy env switch [-h] ...

Switch to a different environment.

positional arguments:
name the name of the configuration entry

options:
-h, --help show this help message and exit

```
### Environment.List


```
$ mxpy env list --help
usage: mxpy env list [-h] ...

List available environments

options:
-h, --help show this help message and exit

```
### Environment.Remove


```
$ mxpy env remove --help
usage: mxpy env remove [-h] ...

Deletes an environment from the env file. Will switch to default env.

positional arguments:
environment The environment to remove from env file.

options:
-h, --help show this help message and exit

```
### Environment.Reset


```
$ mxpy env reset --help
usage: mxpy env reset [-h] ...

Deletes the environment file. Default env will be used.

options:
-h, --help show this help message and exit

```
10 changes: 10 additions & 0 deletions CLI.md.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ generate() {
command "Governance.GetVotingPower" "governance get-voting-power"
command "Governance.GetConfig" "governance get-config"
command "Governance.GetDelegatedVoteInfo" "governance get-delegated-vote-info"

group "Environment" "env"
command "Environment.New" "env new"
command "Environment.Set" "env set"
command "Environment.Get" "env get"
command "Environment.Dump" "env dump"
command "Environment.Switch" "env switch"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch sounds good. Though, about set & get, let's double check with @ccorcoveanu whether this is fine.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get and set sound good (also git has get and set methods for config). what I am thinking is, do we need dump? Or should get without any arguments actually dump the active config?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get without args dumping the entire config sounds good. I've done it with dump to match the mxpy config dump command.

command "Environment.List" "env list"
command "Environment.Remove" "env remove"
command "Environment.Reset" "env reset"
}

generate
2 changes: 1 addition & 1 deletion multiversx_sdk_cli/base_transactions_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
StringValue,
)

from multiversx_sdk_cli.config import get_address_hrp
from multiversx_sdk_cli.constants import (
ADDRESS_PREFIX,
EXTRA_GAS_LIMIT_FOR_GUARDED_TRANSACTIONS,
Expand All @@ -22,6 +21,7 @@
TRUE_STR_LOWER,
)
from multiversx_sdk_cli.cosign_transaction import cosign_transaction
from multiversx_sdk_cli.env import get_address_hrp
from multiversx_sdk_cli.errors import BadUserInput, TransactionSigningError
from multiversx_sdk_cli.guardian_relayer_data import GuardianRelayerData
from multiversx_sdk_cli.interfaces import IAccount
Expand Down
19 changes: 15 additions & 4 deletions multiversx_sdk_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import multiversx_sdk_cli.cli_delegation
import multiversx_sdk_cli.cli_deps
import multiversx_sdk_cli.cli_dns
import multiversx_sdk_cli.cli_env
import multiversx_sdk_cli.cli_faucet
import multiversx_sdk_cli.cli_governance
import multiversx_sdk_cli.cli_ledger
Expand All @@ -26,6 +27,7 @@
import multiversx_sdk_cli.cli_wallet
import multiversx_sdk_cli.version
from multiversx_sdk_cli import config, errors, utils, ux
from multiversx_sdk_cli.env import get_address_hrp

logger = logging.getLogger("cli")

Expand All @@ -45,10 +47,11 @@ def main(cli_args: list[str] = sys.argv[1:]):

def _do_main(cli_args: list[str]):
utils.ensure_folder(config.SDK_PATH)
argv_with_config_args = config.add_config_args(cli_args)
parser = setup_parser(argv_with_config_args)
parser = setup_parser(cli_args)
argcomplete.autocomplete(parser)
args = parser.parse_args(argv_with_config_args)

_handle_verbose_argument(cli_args)
args = parser.parse_args(cli_args)

if args.verbose:
logging.basicConfig(
Expand All @@ -65,7 +68,7 @@ def _do_main(cli_args: list[str]):
)

verify_deprecated_entries_in_config_file()
default_hrp = config.get_address_hrp()
default_hrp = get_address_hrp()
LibraryConfig.default_address_hrp = default_hrp

if hasattr(args, "recall_nonce") and args.recall_nonce:
Expand Down Expand Up @@ -126,6 +129,7 @@ def setup_parser(args: list[str]):
commands.append(multiversx_sdk_cli.cli_faucet.setup_parser(args, subparsers))
commands.append(multiversx_sdk_cli.cli_multisig.setup_parser(args, subparsers))
commands.append(multiversx_sdk_cli.cli_governance.setup_parser(args, subparsers))
commands.append(multiversx_sdk_cli.cli_env.setup_parser(subparsers))

parser.epilog = """
----------------------
Expand All @@ -151,6 +155,13 @@ def verify_deprecated_entries_in_config_file():
ux.show_warning(message.rstrip("\n"))


def _handle_verbose_argument(args: list[str]):
verbose_arg = "--verbose"
if verbose_arg in args:
args.remove(verbose_arg)
args.insert(0, verbose_arg)


if __name__ == "__main__":
ret = main(sys.argv[1:])
sys.exit(ret)
Loading
Loading