Skip to content

v0.19.0

Compare
Choose a tag to compare
@c4spar c4spar released this 26 May 16:55
· 434 commits to main since this release

BREAKING CHANGES

  • keycode: refactor keycode module (#186) (4ac2719)

    Before:

    const key: KeyEvent = KeyCode.parse(
      "\x1b[A\x1b[B\x1b[C\x1b[D\x1b[E\x1b[F\x1b[H",
    );

    After:

    const key: KeyCode = parse("\x1b[A\x1b[B\x1b[C\x1b[D\x1b[E\x1b[F\x1b[H");

Features

  • command: add exitCode option to ValidationError (#201) (d4c0f12)

    throw new ValidationError("Some validation error", { exitCode: 2 });
  • command: add enum type (#197) (36289a2)

    cmd.type("log-level", new EnumType(["debug", "info", 0, 1]))
      .option("-L, --log-level <level:log-level>");
  • command: improve support for generic custom types (#191) (59b1a93)

    const color = new EnumType(["red", "blue", "yellow"]);
    cmd.type("color", color)
      // you can pass the type
      .option<{ color: typeof color }>("-c, --color <name:color>");
  • command: add upgrade command (#203) (348f743)

    // single registry with default options
    cmd.command(
      "upgrade",
      new UpgradeCommand({
        provider: new DenoLandProvider(),
      }),
    );
    
    // multi registry with custom options
    cmd.command(
      "upgrade",
      new UpgradeCommand({
        main: "cli.ts",
        args: ["--allow-net", "--unstable"],
        provider: [
          new DenoLandProvider({ name: "cliffy" }),
          new NestLandProvider({ name: "cliffy" }),
          new GithubProvider({ repository: "c4spar/deno-cliffy" }),
        ],
      }),
    );
  • command: add values method to types to show possible values in help text (#202) (143eb1b, 045c56e)

  • command: allow numbers for completions (#195) (f30b3af)

  • command,flags: add integer type (#190) (2cc7e57)

    cmd.option("-a, --amount <amount:integer>");
  • keycode: add code property to parse result (#182) (366683f)

  • keypress: add keypress module (#187) (5acf5db)

    // promise
    const event: KeyPressEvent = await keypress();
    
    // events
    keypress().addEventListener((event: KeyPressEvent) => {
      console.log("event:", event);
      if (event.ctrlKey && event.key === "c") {
        keypress().dispose();
      }
    });
    
    // async iterator
    for await (const event: KeyPressEvent of keypress()) {
      console.log("event:", event);
      if (event.ctrlKey && event.key === "c") {
        break;
      }
    }
  • prompt: add id option to automatically save suggestions to local storage (#204) (28f25bd)

    await Input.prompt({
      message: "Enter your name",
      id: "<local-storage-key>",
    });

Bug Fixes

  • command,flags: value handler not called for default value if option is not defined on commandline (ef3df5e)
  • keycode: fix esc key and sequence property for escaped keys (b9eb39b)
  • table: fix getBody and hasHeaderBorder methods (2d65cc8)

Code Refactoring

  • command: add CompleteHandlerResult type (#200) (ade3c3d)
  • command: remove unnecessary dependency (#199) (b26f07c)
  • flags: refactor number type (#196) (9b57f54)
  • flags: refactor error message for boolean and number types (#189) (2a19c34)
  • keycode: refactor special key handling (7aaaec4)
  • prompt: enable raw mode only if stdin is a tty (#183) (83c644a)

Chore

Unit/Integration Tests

Documentation Updates

  • command,flags: add integer type to readme (6aec3db)
  • command: fix typo (a965ea3)
  • command: describe getHelp and showHelp (0e674c8)
  • command: documentation fixes (6442ae7)