public async function mainAsync()

in src/InspectorCLI.hack [62:99]


  public async function mainAsync(): Awaitable<int> {
    $err = $this->getStderr();
    if (C\count($this->getArguments()) !== 1) {
      await $err->writeAllAsync("Provide exactly one file name\n");
      return 1;
    }

    $input = C\onlyx($this->getArguments());
    if (!\is_file($input)) {
      await $err->writeAllAsync("Provided path is not a file.\n");
      return 1;
    }

    $ast = await HHAST\from_file_async(HHAST\File::fromPath($input));

    // No XHP as XHP currently doesn't support namespaces
    $output = $this->outputPath ??
      Str\format(
        '%s/hhast-inspect-%s.html',
        Str\strip_suffix(\sys_get_temp_dir(), '/'),
        \bin2hex(\random_bytes(16)),
      );

    \file_put_contents(
      $output,
      await $this->getXHPDocument($ast)->toStringAsync(),
    );

    print $output."\n";

    if ($this->open) {
      if (!self::openFileInBrowser($output)) {
        await $err->writeAllAsync("We failed to open your browser.\n");
      }
    }

    return 0;
  }