2020-02-28 12:02:29 +00:00
|
|
|
import click
|
2021-04-01 09:24:00 +00:00
|
|
|
import sys
|
2020-02-28 12:02:29 +00:00
|
|
|
|
2020-09-28 14:49:37 +00:00
|
|
|
from eth2deposit.cli.existing_mnemonic import existing_mnemonic
|
|
|
|
from eth2deposit.cli.new_mnemonic import new_mnemonic
|
2021-04-08 11:56:10 +00:00
|
|
|
from eth2deposit.utils.click import (
|
|
|
|
captive_prompt_callback,
|
|
|
|
choice_prompt_func,
|
2021-04-19 13:07:13 +00:00
|
|
|
jit_option,
|
2021-04-08 11:56:10 +00:00
|
|
|
)
|
2021-04-01 09:24:00 +00:00
|
|
|
from eth2deposit.utils import config
|
2021-04-08 10:08:59 +00:00
|
|
|
from eth2deposit.utils.constants import INTL_LANG_OPTIONS
|
2021-04-01 09:24:00 +00:00
|
|
|
from eth2deposit.utils.intl import (
|
2021-04-08 10:08:59 +00:00
|
|
|
get_first_options,
|
|
|
|
fuzzy_reverse_dict_lookup,
|
2021-04-01 09:24:00 +00:00
|
|
|
load_text,
|
|
|
|
)
|
2020-02-28 12:02:29 +00:00
|
|
|
|
|
|
|
|
2020-05-19 13:34:16 +00:00
|
|
|
def check_python_version() -> None:
|
2020-03-10 18:40:19 +00:00
|
|
|
'''
|
|
|
|
Checks that the python version running is sufficient and exits if not.
|
|
|
|
'''
|
|
|
|
if sys.version_info < (3, 7):
|
2021-04-01 09:24:00 +00:00
|
|
|
click.pause(load_text(['err_python_version']))
|
2020-03-10 18:40:19 +00:00
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
|
2020-09-28 14:49:37 +00:00
|
|
|
@click.group()
|
2021-04-01 09:24:00 +00:00
|
|
|
@click.pass_context
|
2021-04-19 13:07:13 +00:00
|
|
|
@jit_option(
|
2021-04-01 09:24:00 +00:00
|
|
|
'--language',
|
2021-04-08 11:56:10 +00:00
|
|
|
callback=captive_prompt_callback(
|
|
|
|
lambda language: fuzzy_reverse_dict_lookup(language, INTL_LANG_OPTIONS),
|
|
|
|
choice_prompt_func(lambda: 'Please choose your language', get_first_options(INTL_LANG_OPTIONS))(),
|
|
|
|
),
|
2021-04-01 09:24:00 +00:00
|
|
|
default='English',
|
2021-04-19 10:30:40 +00:00
|
|
|
help='The language you wish to use the CLI in.',
|
2021-04-08 11:56:10 +00:00
|
|
|
prompt=choice_prompt_func(lambda: 'Please choose your language', get_first_options(INTL_LANG_OPTIONS))(),
|
2021-04-01 09:24:00 +00:00
|
|
|
type=str,
|
|
|
|
)
|
|
|
|
def cli(ctx: click.Context, language: str) -> None:
|
|
|
|
config.language = language
|
2020-02-28 12:02:29 +00:00
|
|
|
|
|
|
|
|
2020-09-28 14:49:37 +00:00
|
|
|
cli.add_command(existing_mnemonic)
|
|
|
|
cli.add_command(new_mnemonic)
|
|
|
|
|
2020-09-28 15:20:08 +00:00
|
|
|
|
2020-02-28 12:02:29 +00:00
|
|
|
if __name__ == '__main__':
|
2020-09-28 14:49:37 +00:00
|
|
|
check_python_version()
|
|
|
|
cli()
|