diff --git a/analysis/reanalyze/src/Reanalyze.ml b/analysis/reanalyze/src/Reanalyze.ml index 7378264908..0f150a4a40 100644 --- a/analysis/reanalyze/src/Reanalyze.ml +++ b/analysis/reanalyze/src/Reanalyze.ml @@ -106,11 +106,12 @@ let runAnalysisAndReport ~cmtRoot = let cli () = let analysisKindSet = ref false in let cmtRootRef = ref None in - let usage = "reanalyze version " ^ Version.version in - let versionAndExit () = - print_endline usage; - exit 0 - [@@raises exit] + let usage = + {|Usage: rescript reanalyze [options] + +`rescript reanalyze` is powerful dead code analysis tools to maintain a clean, efficient, and distraction-free codebase + +Options:|} in let rec setAll cmtRoot = RunConfig.all (); @@ -203,8 +204,6 @@ let cli () = "comma-separated-path-prefixes Report on files whose path has a prefix \ in the list, overriding -suppress (no-op if -suppress is not \ specified)" ); - ("-version", Unit versionAndExit, "Show version information and exit"); - ("--version", Unit versionAndExit, "Show version information and exit"); ( "-write", Set Common.Cli.write, "Write @dead annotations directly in the source files" ); diff --git a/analysis/reanalyze/src/Version.ml b/analysis/reanalyze/src/Version.ml deleted file mode 100644 index 4361834b43..0000000000 --- a/analysis/reanalyze/src/Version.ml +++ /dev/null @@ -1,4 +0,0 @@ -(* CREATED BY reanalyze/scripts/bump_version_module.js *) -(* DO NOT MODIFY BY HAND, WILL BE AUTOMATICALLY UPDATED BY npm version *) - -let version = "2.22.0" diff --git a/cli/rescript.js b/cli/rescript.js index 98d8900ab2..beed6bfd43 100755 --- a/cli/rescript.js +++ b/cli/rescript.js @@ -6,10 +6,11 @@ // It matters since we need read .sourcedirs(location) // and its content are file/directories with regard to project root -import * as tty from "node:tty"; +import * as child_process from "node:child_process"; import * as fs from "node:fs"; +import * as tty from "node:tty"; -import { bsc_exe, rescript_exe } from "./common/bins.js"; +import { bsc_exe, rescript_exe, rescript_tools_exe } from "./common/bins.js"; import * as bsb from "./common/bsb.js"; const cwd = process.cwd(); @@ -44,6 +45,8 @@ Subcommands: build clean format + doc + reanalyze dump help @@ -94,7 +97,7 @@ if ( console.log(helpMessage); } else if (argPatterns.version.includes(args[0])) { const packageSpec = JSON.parse( - fs.readFileSync(new URL("../package.json", import.meta.url), "utf-8") + fs.readFileSync(new URL("../package.json", import.meta.url), "utf-8"), ); console.log(packageSpec.version); @@ -125,6 +128,16 @@ if ( mod.main(subcmdArgs, rescript_exe, bsc_exe); break; } + case "doc": { + const args = process.argv.slice(2); + child_process.spawnSync(rescript_tools_exe, args, { stdio: "inherit" }); + break; + } + case "reanalyze": { + const args = process.argv.slice(2); + child_process.spawnSync(rescript_tools_exe, args, { stdio: "inherit" }); + break; + } default: { console.error(`Error: Unknown command "${subcmd}".\n${helpMessage}`); process.exit(2); diff --git a/tests/build_tests/cli_help/input.js b/tests/build_tests/cli_help/input.js index facfbecf2b..07dde314ab 100755 --- a/tests/build_tests/cli_help/input.js +++ b/tests/build_tests/cli_help/input.js @@ -19,6 +19,8 @@ const cliHelp = " build\n" + " clean\n" + " format\n" + + " doc\n" + + " reanalyze\n" + " dump\n" + " help\n" + "\n" + diff --git a/tools/bin/main.ml b/tools/bin/main.ml index 2d97dea930..811d974fc6 100644 --- a/tools/bin/main.ml +++ b/tools/bin/main.ml @@ -1,11 +1,7 @@ let docHelp = - {|ReScript Tools - -Output documentation to standard output + {|Usage: rescript doc [file] -Usage: rescript-tools doc - -Example: rescript-tools doc ./path/to/EntryPointLib.res|} +`rescript doc` generate documentation and print to standard output|} let help = {|ReScript Tools @@ -16,7 +12,6 @@ Commands: doc Generate documentation reanalyze Reanalyze --v, --version Print version -h, --help Print help|} let logAndExit = function @@ -27,8 +22,6 @@ let logAndExit = function Printf.eprintf "%s\n" log; exit 1 -let version = Version.version - let main () = match Sys.argv |> Array.to_list |> List.tl with | "doc" :: rest -> ( @@ -77,7 +70,6 @@ let main () = close_out oc; exit 0 | ["-h"] | ["--help"] -> logAndExit (Ok help) - | ["-v"] | ["--version"] -> logAndExit (Ok version) | _ -> logAndExit (Error help) let () = main () diff --git a/tools/bin/version.ml b/tools/bin/version.ml deleted file mode 100644 index 8a00911bbc..0000000000 --- a/tools/bin/version.ml +++ /dev/null @@ -1 +0,0 @@ -let version = "0.6.4"