Skip to content

Tools: use cmdliner library to parse arguments #910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,29 @@ jobs:
path: ~/.opam
key: ${{matrix.os}}-rescript-vscode-v4

- name: Use OCaml
- name: Use OCaml ${{matrix.ocaml_compiler}}
uses: ocaml/setup-ocaml@v2
if: matrix.os != 'windows-latest'
with:
ocaml-compiler: 4.14.x

- name: Use OCaml ${{matrix.ocaml_compiler}} (Win)
uses: ocaml/setup-ocaml@v2
if: matrix.os == 'windows-latest'
with:
ocaml-compiler: 4.14.x
opam-repositories: |
sunset: https://github.com/ocaml-opam/opam-repository-mingw.git#sunset
default: https://github.com/ocaml/opam-repository.git

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'

- run: npm ci
- run: opam install dune cppo
- run: opam install . --deps-only --with-doc --with-test
- run: npm run compile

# These 2 runs (or just the second?) are for when you have opam dependencies. We don't.
Expand Down
1 change: 0 additions & 1 deletion analysis/reanalyze/examples/deadcode/expected/deadcode.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Scanning AutoAnnotate.cmt Source:AutoAnnotate.res
addVariantCaseDeclaration R AutoAnnotate.res:1:15 path:+AutoAnnotate.variant
addRecordLabelDeclaration variant AutoAnnotate.res:4:15 path:+AutoAnnotate.record
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@


Exception Analysis
Exn.res:1:5-10
raises might raise Not_found (Exn.res:1:19) and is not annotated with @raises(Not_found)
Expand Down
4 changes: 2 additions & 2 deletions analysis/reanalyze/examples/deadcode/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ else
exclude_dirs="src/exception"
suppress="src/ToSuppress.res"
fi
dune exec rescript-editor-analysis -- reanalyze -config -debug -ci -exclude-paths $exclude_dirs -live-names globallyLive1 -live-names globallyLive2,globallyLive3 -suppress $suppress > $output
dune exec -- rescript-tools reanalyze --dce --config --debug --ci --exclude-paths $exclude_dirs --live-names globallyLive1,globallyLive2,globallyLive3 --suppress $suppress > $output
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
if [ "$RUNNER_OS" == "Windows" ]; then
perl -pi -e 's/\r\n/\n/g' -- $output
Expand All @@ -18,7 +18,7 @@ if [ "$RUNNER_OS" == "Windows" ]; then
else
unsuppress_dirs="src/exception"
fi
dune exec rescript-editor-analysis -- reanalyze -exception -ci -suppress src -unsuppress $unsuppress_dirs > $output
dune exec -- rescript-tools reanalyze --exception --ci --suppress src --unsuppress $unsuppress_dirs > $output
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
if [ "$RUNNER_OS" == "Windows" ]; then
perl -pi -e 's/\r\n/\n/g' -- $output
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Scanning TestCyberTruck.cmt Source:TestCyberTruck.res

Function Table
Expand Down
2 changes: 1 addition & 1 deletion analysis/reanalyze/examples/termination/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output="expected/termination.txt"
dune exec rescript-editor-analysis -- reanalyze -config -ci -debug > $output
dune exec -- rescript-tools reanalyze --termination --config --ci --debug > $output
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
if [ "$RUNNER_OS" == "Windows" ]; then
perl -pi -e 's/\r\n/\n/g' -- $output
Expand Down
3 changes: 3 additions & 0 deletions analysis/reanalyze/src/Reanalyze.ml
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,6 @@ let cli () =

module RunConfig = RunConfig
module Log_ = Log_
module Common = Common
module Paths = Paths
module DeadCommon = DeadCommon
2 changes: 2 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@
(>= 4.10))
(cppo
(= 1.6.9))
(cmdliner
(>= 1.2))
analysis
dune))
1 change: 1 addition & 0 deletions tools.opam
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ bug-reports: "https://github.com/rescript-lang/rescript-vscode/issues"
depends: [
"ocaml" {>= "4.10"}
"cppo" {= "1.6.9"}
"cmdliner" {>= "1.2"}
"analysis"
"dune"
]
Expand Down
7 changes: 7 additions & 0 deletions tools/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

## master

## 0.6.0

#### :boom: Breaking Change

- Reanalyze subcommand arguments now starts with two dash `--`. Some commands removed. https://github.com/rescript-lang/rescript-vscode/pull/910
- ReScript Tools command now generate man pages following GNU conventions. https://github.com/rescript-lang/rescript-vscode/pull/910

## 0.5.0

#### :rocket: New Feature
Expand Down
2 changes: 1 addition & 1 deletion tools/bin/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
(modes byte exe)
; The main module that will become the binary.
(name main)
(libraries tools)
(libraries tools analysis cmdliner)
(flags
(-w "+6+26+27+32+33+39")))
Loading