/nircmd-fluent

Windows utility library with fluent API, underpinned by NirCmd.

Primary LanguageTypeScriptMIT LicenseMIT

NirCmd Fluent API

Version License: MIT Open Issues Size

Description

  • 🎉 First class Typescript support
  • ✨ Fluent API to compose commands
  • 🌈 Returns the full result
  • 0️⃣ Zero dependencies
  • 👌 Maps directly to NirCmd API

Table of Contents

Install

yarn add nircmd-fluent
npm install nircmd-fluent

Usage

Commands, actions and additional parameters are chained together via a fluent api (with the aid of type inference for typescript users) and executed with a final run() method call.

All commands are executed asynchronously, returning a native node promise that should be awaited.

Commands are composed as you would read them from the NirCmd command reference. For example:

await NirCmd.win().setsize(300, 200, 1280, 720).title("Notepad").run();

Example bringing the window containing the sequence of characters "Fortnite" to the foreground.

import { NirCmd } from "nircmd-fluent";

(async () => {
    let output: string;
    try {
        output = await NirCmd.win().show().ititle("Fortnite").run();
    } catch (error) {
        console.error(`Failed to bring window to foreground: ${output}`);
    }
    console.log(output);
})();

Examples

More examples can be found in the examples directory.

There are example implementations for both javascript and typescript.

➜ yarn example
$ ts-node example/index.ts

Example output

Run tests

yarn test

Author

👤 Jarvis Prestidge jarvisprestidge@gmail.com

Twitter: jarvisprestidge

Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!