Determine subcommand

If I run deno test from the command line, how can I determine that test is the subcommand being run. The command is not present in Deno.args, nor Deno.mainModule Thanks in advance!
DAHDeno AI Helper9/22/2023
In Deno, the Deno.args array only contains the arguments passed to the script, not the command or subcommand used to run the script. The Deno.mainModule property gives the URL of the main module being executed, not the command or subcommand. The test in deno test is a subcommand of the deno command-line interface (CLI), and it's used to run tests in Deno. However, this subcommand is not accessible from within the script itself. It's processed by the Deno CLI before your script is run, and it's not included in Deno.args or Deno.mainModule. So, from within a Deno script, there's no built-in way to determine that test was the subcommand used to run the script. The Deno runtime doesn't provide this information to the script. If you need this information within your script, you would need to pass it as an argument when running the script. For example, you could run deno run main.ts test and then access Deno.args[0] to get the string 'test'. Please note that this information is not explicitly stated in the documentation.

Looking for more? Join the community!