I was trying to build a cli app using commander module and I was trying to port the following example to rescript
import { Command } from 'commander';
const program = new Command();
program
.name('string-util')
.description('CLI to some JavaScript string utilities')
.version('0.8.0');
program.command('split')
.description('Split a string into substrings and display as an array')
.argument('<string>', 'string to split')
.option('--first', 'display just the first substring')
.option('-s, --separator <char>', 'separator character', ',')
.action((str, options) => {
const limit = options.first ? 1 : undefined;
console.log(str.split(options.separator, limit));
});
program.parse();
the corresponding .res file looks like this
type t = {"name": string, "description": string, "version": string}
@new @module("commander") external command: unit => t = "Command"
let program = command()
program["name"] = `string-util`
I am getting the following error when I try to build it
❯ yarn res:build
yarn run v1.22.19
$ rescript
rescript: [1/1] src/Demo.cmj
FAILED: src/Demo.cmj
We've found a bug for you!
/home/sk/rescript-project-template/src/Demo.res:7:1-7
5 │ let program = command()
6 │
7 │ program["name"] = `string-util`
8 │
This expression has type t
It has no field name#=
Hint: Did you mean name?
FAILED: cannot make progress due to previous errors.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Even though I have specified the name
field in type t
it still is not able to find it