Skip to content

Rework transpilation syntax CLI options

Nicolas Phan requested to merge transpile_opt_shortcut into dev

Motivation and Context

This is a tentative to clarify the CLI options for specifying transpilation input and output syntax.

Description

To specify the source syntax

Before : --syntax was used

Problem : It's not clear if --syntax refers to source or dest syntax

After : --from-syntax is used

To specify the dest syntax

Before : jsligo / jsligo -o dest.jsligo

Problem :

  1. The CLI option for dest syntax doesn't follow the same format as source syntax.
  2. The CLI option is redundant if output file is already specified, because dest syntax can be infered from output file extension.

After : --to-syntax jsligo / -o dest.jsligo

Component

  • compiler
  • website
  • webide
  • vscode-plugin
  • debugger

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Performance improvement (non-breaking change that improves performance)
  • None (change with no changelog)

Changelog

Before

> ligo transpile contract input.ligo
Error parsing command line:

  missing anonymous argument: SYNTAX

For usage information, run

  ligo transpile contract -help
> ligo transpile contract --from-syntax pascaligo input.ligo --to-syntax jsligo
Error parsing command line:

  unknown flag --from-syntax

For usage information, run

  ligo transpile contract -help
ligo transpile contract input.ligo -o output.jsligo
Error parsing command line:

  missing anonymous argument: SYNTAX

For usage information, run

  ligo transpile contract -help

After

> ligo transpile contract input.ligo
Transpilation target syntax is not specified.
Please provide it using the --to-syntax option
or by specifying an output file with the -o option  
> ligo transpile contract --from-syntax pascaligo input.ligo --to-syntax jsligo
# 1 "input.ligo"
# 1 "input.ligo"
type storage = int;

type parameter = | ["Increment", int] | ["Decrement", int] | ["Reset"];
...
const main = 
  (action: parameter, store: storage): @return => 
    [list([]) as list<operation>, match(action, { Increment: n => add(store, n), Decrement: n => sub(store, n), Reset: () => 0})];
> ligo transpile contract input.ligo -o output.jsligo

Checklist:

  • Changes follow the existing coding style (use dune @fmt to check).
  • Tests for the changes have been added (for bug fixes / feature).
  • Documentation has been updated.
  • Changelog description has been added (if appropriate).
  • Start titles under ## Changelog section with #### (if appropriate).
  • There is no image or uploaded file in changelog
  • Examples in changed behaviour have been added to the changelog (for breaking change / feature).
Edited by Nicolas Phan

Merge request reports