informalsystems / themis-contract

A command line-based parameterized contracting tool
Apache License 2.0
46 stars 5 forks source link

If environment variable is needed before running a command, show error before proceeding with questions #44

Open andynog opened 4 years ago

andynog commented 4 years ago

Tried to run the command to create a new contract and after inputing the template location, got an error message that the $EDITOR environment variable needs to be set. Probably a better UX would be to prompt the user to configure the environment variable before proceeding with the questions because in this case a contract.toml was actually created but without the parameters filled in.

$ themis-contract new
? Would you like to prepopulate the contract with variables from a template? Yes
? Where is the template located? (Git/HTTPS URL or file path) {URL TYPED HERE}
2020-05-20 14:17:03 info Created new contract: contract.toml
2020-05-20 14:17:03 error 
Your $EDITOR environment variable is not set.
Set it to the command/path of your editor in ~/.zshenv or ~/.bashrc:

  export EDITOR=atom
andynog commented 4 years ago

I just realized that after setting the environment variable and running the command again the contract.toml is created the same way as not having the environment variable set so this might not be an issue. I believe that maybe this error message should just include additional details that the tools tries to open the newly created file in the editor but failed because the variable was not set but let the user know that the new command was completed successfully.