near / nearup

Public scripts to launch NEAR Protocol betanet and testnet node
102 stars 33 forks source link

Introduce util.wraptext and make prompt_* functions use it #206

Closed mina86 closed 2 years ago

mina86 commented 2 years ago

Rather than repeating the same textwrap.fill(textwrap.dedent(...)) idiom in multiple places, wrap it into util.wraptext function. It’s not exactly equivalent since it ignores all leading white space (rather than dedenting common spaces) and treats empty lines as paragraph separators with paragraphs filled independently and separated by empty lines in output.

Furthermore, make util.prompt_bool_flag and util.prompt_flag functions call the wraptext on prompt message so that caller of those functions doesn’t have to do it themselves. For short one-line prompts it doesn’t end up making any difference.