Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/denops_std/argument/opts.ts>parseOpts

๐Ÿ“š Standard module for denops.vim
Latest
function parseOpts
import { parseOpts } from "https://deno.land/x/denops_std@v6.5.1/argument/opts.ts";

Parse string array to extract opts (++opt).

import type { Entrypoint } from "https://deno.land/x/denops_std@v6.5.1/mod.ts";
import { parseOpts } from "https://deno.land/x/denops_std@v6.5.1/argument/mod.ts";

export const main: Entrypoint = async (denops) => {
  const args = [
    "++enc=sjis",
    "++ff=dos",
    "-f",
    "--foo=foo",
    "--bar=bar",
    "--bar=baz",
    "hello",
    "world",
  ];
  const [opts, residues] = parseOpts(args);

  console.log(opts);
  // { "enc": "sjis", "ff": "dos" }

  console.log(residues);
  // ["-f", "--foo=foo", "--bar=bar", "--bar=baz", "hello", "world"]
}

Parameters

args: string[]

Returns

[Opts, string[]]