o1-labs / zkapp-cli

CLI to create a zkApp (zero-knowledge app) for Mina Protocol
https://docs.minaprotocol.com/zkapps/how-to-write-a-zkapp
Apache License 2.0
115 stars 44 forks source link

Make error indentation DRY #169

Open ymekuria opened 2 years ago

ymekuria commented 2 years ago

The error message formatting appears inconsistent after the first line. The first line is indented but every following line appears to be aligned to the left of the screen.

✔ Build project ✔ Generate build.json ✔ Choose smart contract The 'Add' smart contract will be used for this network as specified in config.json. Failed to find the "Add" smart contract in your build directory. Check that you have exported your smart contract class using a named export and try again.

jasongitmail commented 2 years ago

Related: To make it more DRY, we could store the indent string as a var and prepend it to messages.

ymekuria commented 2 years ago

Related: To make it more DRY, we could store the indent string as a var and prepend it to messages.

I like that idea!

jasongitmail commented 2 years ago

The output in the original post looks ok in my terminal:

✔ Build project
✔ Generate build.json
✔ Choose smart contract
  Only one smart contract exists in the project: Add
  Your config.json was updated to always use this
  smart contract when deploying to this network.

I think the affected error messages indentation on 2nd lines are fixed here: https://github.com/o1-labs/zkapp-cli/pull/191 Updated the title to focus on making indentation DRY, to prevent such errors. (Another solution would be a method that accepts an error string, makes it red, and adds a line break and two spaces automatically while keeping the error string within a certain max char length and breaking intelligently to not split words.)