BARGS
    Preparing search index...

    Variable optConst

    opt: {
        array: {
            (
                items: "string" | "number",
                props?: Omit<ArrayOption, "type" | "items">,
            ): ArrayOption;
            <const T extends readonly string[]>(
                choices: T,
                props?: Omit<EnumArrayOption<T[number]>, "type" | "choices">,
            ): EnumArrayOption<T[number]>;
        };
        boolean: <
            P extends Omit<BooleanOption, "type"> = Omit<BooleanOption, "type">,
        >(
            props?: P,
        ) => BooleanOption & P;
        count: (props?: Omit<CountOption, "type">) => CountOption;
        enum: <
            const T extends readonly string[],
            P extends
                Omit<EnumOption<T[number]>, "type" | "choices"> = Omit<
                EnumOption<T[number]>,
                "type" | "choices",
            >,
        >(
            choices: T,
            props?: P,
        ) => EnumOption<T[number]> & P;
        enumPos: <
            const T extends readonly string[],
            P extends
                Omit<EnumPositional<T[number]>, "type" | "choices"> = Omit<
                EnumPositional<T[number]>,
                "type" | "choices",
            >,
        >(
            choices: T,
            props?: P,
        ) => EnumPositional<T[number]> & P;
        number: <P extends Omit<NumberOption, "type"> = Omit<NumberOption, "type">>(
            props?: P,
        ) => NumberOption & P;
        numberPos: <
            P extends
                Omit<NumberPositional, "type"> = Omit<NumberPositional, "type">,
        >(
            props?: P,
        ) => NumberPositional & P;
        options: <T extends OptionsSchema>(
            schema: T,
        ) => CallableOptionsParser<InferOptions<T>>;
        string: <P extends Omit<StringOption, "type"> = Omit<StringOption, "type">>(
            props?: P,
        ) => P & StringOption;
        stringPos: <
            P extends
                Omit<StringPositional, "type"> = Omit<StringPositional, "type">,
        >(
            props?: P,
        ) => P & StringPositional;
        variadic: (
            items: "string" | "number",
            props?: Omit<VariadicPositional, "items" | "type">,
        ) => VariadicPositional;
    } = ...

    Namespaced option builders.

    Type Declaration

    • array: {
          (
              items: "string" | "number",
              props?: Omit<ArrayOption, "type" | "items">,
          ): ArrayOption;
          <const T extends readonly string[]>(
              choices: T,
              props?: Omit<EnumArrayOption<T[number]>, "type" | "choices">,
          ): EnumArrayOption<T[number]>;
      }

      Define an array option (--flag value --flag value2).

      // Primitive array
      opt.array('string'); // --file a.txt --file b.txt → ['a.txt', 'b.txt']
      opt.array('number'); // --port 80 --port 443 → [80, 443]

      // Enum array (with choices)
      opt.array(['low', 'medium', 'high']); // --priority low --priority high
    • Functionboolean: <P extends Omit<BooleanOption, "type"> = Omit<BooleanOption, "type">>(
          props?: P,
      ) => BooleanOption & P

      Define a boolean option.

    • Functioncount: (props?: Omit<CountOption, "type">) => CountOption

      Define a count option (--verbose --verbose = 2).

    • Functionenum: <
          const T extends readonly string[],
          P extends
              Omit<EnumOption<T[number]>, "type" | "choices"> = Omit<
              EnumOption<T[number]>,
              "type" | "choices",
          >,
      >(
          choices: T,
          props?: P,
      ) => EnumOption<T[number]> & P

      Define an enum option with string choices.

    • FunctionenumPos: <
          const T extends readonly string[],
          P extends
              Omit<EnumPositional<T[number]>, "type" | "choices"> = Omit<
              EnumPositional<T[number]>,
              "type" | "choices",
          >,
      >(
          choices: T,
          props?: P,
      ) => EnumPositional<T[number]> & P

      Define an enum positional argument with string choices.

    • Functionnumber: <P extends Omit<NumberOption, "type"> = Omit<NumberOption, "type">>(
          props?: P,
      ) => NumberOption & P

      Define a number option.

    • FunctionnumberPos: <P extends Omit<NumberPositional, "type"> = Omit<NumberPositional, "type">>(
          props?: P,
      ) => NumberPositional & P

      Define a number positional argument.

    • options: <T extends OptionsSchema>(schema: T) => CallableOptionsParser<InferOptions<T>>

      Create a Parser from an options schema.

      const parser = opt.options({
      verbose: opt.boolean({ aliases: ['v'] }),
      name: opt.string({ default: 'world' }),
      });
      // Type: Parser<{ verbose: boolean | undefined, name: string }, []>
    • Functionstring: <P extends Omit<StringOption, "type"> = Omit<StringOption, "type">>(
          props?: P,
      ) => P & StringOption

      Define a string option.

    • FunctionstringPos: <P extends Omit<StringPositional, "type"> = Omit<StringPositional, "type">>(
          props?: P,
      ) => P & StringPositional

      Define a string positional argument.

    • Functionvariadic: (
          items: "string" | "number",
          props?: Omit<VariadicPositional, "items" | "type">,
      ) => VariadicPositional

      Define a variadic positional (rest args).

    import { opt } from 'bargs';

    const parser = opt.options({
    verbose: opt.boolean({ aliases: ['v'] }),
    name: opt.string({ default: 'world' }),
    level: opt.enum(['low', 'medium', 'high']),
    });