All Projects ā†’ vutran ā†’ Wonders

vutran / Wonders

Licence: mit
šŸŒˆ Declarative JavaScript framework to build command-line applications.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Wonders

Rang
A Minimal, Header only Modern c++ library for terminal goodies šŸ’„āœØ
Stars: āœ­ 1,080 (+3076.47%)
Mutual labels:  cli, terminal, command-line, console
Tooling
Advancing Node.js as a framework for writing great tools
Stars: āœ­ 98 (+188.24%)
Mutual labels:  cli, terminal, command-line, console
Crossline
A small, self-contained, zero-config, MIT licensed, cross-platform, readline and libedit replacement.
Stars: āœ­ 53 (+55.88%)
Mutual labels:  cli, terminal, command-line, console
Word Wrap
Wrap words to a specified length.
Stars: āœ­ 107 (+214.71%)
Mutual labels:  cli, terminal, command-line, console
Cointop
A fast and lightweight interactive terminal based UI application for tracking cryptocurrencies šŸš€
Stars: āœ­ 2,912 (+8464.71%)
Mutual labels:  cli, terminal, command-line, console
Jquery.terminal
jQuery Terminal Emulator - JavaScript library for creating web-based terminals with custom commands
Stars: āœ­ 2,623 (+7614.71%)
Mutual labels:  cli, terminal, command-line, console
Window Size
Reliable way to to get the height and width of the terminal/console in a node.js environment.
Stars: āœ­ 79 (+132.35%)
Mutual labels:  cli, terminal, command-line, console
Nnn
nĀ³ The unorthodox terminal file manager
Stars: āœ­ 13,138 (+38541.18%)
Mutual labels:  cli, terminal, command-line, console
Mandown
man-page inspired Markdown viewer
Stars: āœ­ 173 (+408.82%)
Mutual labels:  cli, terminal, command-line, console
Ascii
šŸ‘¾ ASCII Roulette :: ascii art video chat on the cli
Stars: āœ­ 202 (+494.12%)
Mutual labels:  cli, terminal, command-line, console
Laravel Zero
A PHP framework for console artisans
Stars: āœ­ 2,821 (+8197.06%)
Mutual labels:  cli, terminal, command-line, console
Nve
Run any command on specific Node.js versions
Stars: āœ­ 531 (+1461.76%)
Mutual labels:  cli, terminal, command-line
Vhtml
Render JSX/Hyperscript to HTML strings, without VDOM šŸŒˆ
Stars: āœ­ 556 (+1535.29%)
Mutual labels:  virtual-dom, vdom, jsx
Radian
A 21 century R console
Stars: āœ­ 878 (+2482.35%)
Mutual labels:  cli, terminal, console
Progressbar
Terminal-based progress bar for Java / JVM
Stars: āœ­ 625 (+1738.24%)
Mutual labels:  cli, terminal, console
Buku
šŸ”– Personal mini-web in text
Stars: āœ­ 4,825 (+14091.18%)
Mutual labels:  terminal, command-line, console
Googler
šŸ” Google from the terminal
Stars: āœ­ 5,594 (+16352.94%)
Mutual labels:  terminal, command-line, console
Sultan
Sultan: Command and Rule over your Shell
Stars: āœ­ 625 (+1738.24%)
Mutual labels:  cli, terminal, command-line
Cheat.sh
the only cheat sheet you need
Stars: āœ­ 27,798 (+81658.82%)
Mutual labels:  cli, terminal, command-line
Bat
A cat(1) clone with wings.
Stars: āœ­ 30,833 (+90585.29%)
Mutual labels:  cli, terminal, command-line

Wonders

A JavaScript library for building command-line applications with JSX.

NOTE: This framework is currently in its initial stage of development and is still highly experimental. Not all features have been implemented yet so please feel free to help contribute towards features, bugs, and documentations where necessary.

Install

Install via npm or yarn

$ npm i -S wonders

# or with yarn:

$ yarn add wonders

Setup

Import Wonders in your files.

import Wonders from 'wonders';

// Declare the JSX pragma
/** @jsx Wonders.Component */

Instead of declaring the JSX pragma in each file, it is recommended to install babel-preset-wonders which includes all the necessary babel presets and plugins to get you started with Wonders.

{
    "presets": ["wonders"]
}

Program Layout

A simple <program/> will consist of multiple <commands/>. These elements are handled internally by the renderer.

A simple structure would look something like this:

const App = (
    <program version="1.0.0" args={process.argv}>
        <command name="foo">Foo!</command>
        <command name="bar">Bar!</command>
        <command name="baz">Baz!</command>
    </program>
);

The example above will only render and execute the <command name="foo" />.

$ ./cli.js foo

# -> Foo!

Creating Your First Command Line Application

Wonders can render to any stream. For this example, we will be writing to process.stdout so our command-line application can work.

We will need to pass the argument list (from the user input) into the <program /> element.

#!/usr/bin/env node

// file: ./cli.js

import Wonders from 'wonders';

const App = (
    <program args={process.argv}>
        <command name="hello">
            Hello, World!
        </command>
    </program>
);

Wonders.render(<App />, process.stdout);

Running the script will result with:

$ ./cli.js hello

# -> Hello, World!

Asynchronous Actions

Wonders supports for rendering output from asynchronous task. Suppose you want to write a script that would deploy something to a remote server. A simple example can be written like so:

const deploy = () => {
    return new Promise((resolve) => {
        // perform remote server deployment
        setTimeout(() => {
            // resolve with a message once finished.
            resolve('Deployed!');
        }, 5000);
    });
};

const App = (
    <program args={process.argv}>
        <command name="deploy" onAction={deploy} />
    </program>
);

Wonders.render(<App />, process.stdout);
$ ./cli.js deploy

# .... waits 5 seconds
# -> Deployed!

Functional and Class Components

Wonders follow the same patterns as React when building reusable components for your <command/>.

The simplest way to write a component is to write a regular function.

function beep() {
    return 'Beep!';
}

Or as an ES6 class:

class Boop extends Wonders.Component {
    render() {
        return <p>Boop!</p>;
    }
}

You can feel free to compose your components and stylize your output as necessary.

import Wonders from 'wonders';

export function stylize() {
    return (
        <div>
            <p><strong>This is bold text.</strong></p>
            <p><em>This is italicized text.</em></p>
            <p><u>This is underlined text.</u></p>
        </div>
    );
}

Demo Application

See the codebase for a working demo application below:

https://github.com/vutran/wonders-demo

LICENSE

MIT Ā© Vu Tran

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].