Skip to main content

Compact developer tools 0.2.0

Compact developer tools 0.2.0 release notes

Today we are releasing Compact developer tools 0.2.0. It supports updating the Compact developer tools itself and the new Compact formatter tool which is released with Compact compiler 0.25.0. The formatter follows TypeScript and programming languages convention to format Compact code.

New Features

Compact Self Update

To update the Compact developer tool run:

$ compact self update
downloading compact 0.2.0 aarch64-apple-darwin
installing to /Users/my-name/.local/bin
compact
everything's installed!
compact: compact -- Update installed -- 0.2.0

Formatter

You need to update your Compact compiler to be able to use the formatter. Simply run:

$ compact update
compact: aarch64-darwin -- 0.25.0 -- installed
compact: aarch64-darwin -- 0.25.0 -- default.

If you do not update your Compact compiler and attempt to use the formatter you will get Error: formatter not available.

To format all Compact contracts in-place in the current directory (inclusive of subdirectories) run:

$ compact format

If the formatter cannot parse a contract you will get some-contract.compact: failed. However, if the formatter is successful it will format your contracts in-place and you will not get any feedback from the Compact developer tool.

To format Compact contracts in a directory in-place (inclusive of subdirectories) run:

$ compact format <my-directory.compact>

To format a list of Compact contract in-place run:

$ compact format <contract-1.compact> <contract-2.compact> <...>

To check if Compact contracts in the currect directory (inclusive of subdirectories) are properly formatted run:

$ compact format --check

This is a convenient flag that will return an error if some Compact code is not properly formatted. If you have contracts that are not properly formatted you will get the contract name, the orignal line prefixed with - and the propely formatted line prefixed with +. For example:

./some-contract.compact:
22 | george,
23 | }
24 |
- 25 | -export struct Structure {
+ 25 | +export struct Structure {
26 | a: Names;
27 | }
28 |

To ask for help on how to use the formatter run:

$ compact help format