1.1.1 • Published 9 years ago

shellscript-ts v1.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

shellscript-ts

A nodejs module for creating shellscript in TypeScript.

CircleCI badge npm version npm downloads npm license Dependency Status

Important

This module is deprecated. It is no longer maintained. Please use ES6 on nodejs v4 or later.

#!/usr/bin/env node --use_strict

class HelloWorld {
  sayHello() {
    console.log("Hello, World!");
  }
}
new HelloWorld().sayHello();

Install

With npm do:

$ npm install -g shellscript-ts

Usage

Put a shebang line on top of your shellscript.

#!/usr/bin/env shellscript-ts

Sample shellscript

Parse arguments

#!/usr/bin/env shellscript-ts

/// <reference path="node.d.ts" />

var options = require('optimist')
    .usage('Sample script for shellscript-ts.\nUsage: $0 [options] URL')
    // --help
    .describe('h', 'Print this message')
    .alias('h', 'help')
    .default('h', false)
    .boolean(['h']);

class ParseArgs {

  execute(): void {
    var argv = options.argv;

    if (argv.h) {
      this.options.showHelp();
      process.exit(1);
    }

    console.log("argv=", argv);
  }
}
new ParseArgs().execute();

HTTP GET

#!/usr/bin/env shellscript-ts

/// <reference path="node.d.ts" />

var http = require('http');

class HttpClient {

  execute(): void {
    var url = process.argv[2];

    http.get(url, function(res) {
      console.log(res.statusCode);
      console.log();
      for (var key in res.headers) {
        console.log(key + "=" + res.headers[key]);
      }
      console.log();

      res.on("data", function(chunk) {
        console.log("" + chunk);
      });
    }).on('error', function(e) {
      console.log("Error : " + e.message);
    });
  }
}
new HttpClient().execute();

Building

In order to build the shellscript-ts, ensure that you have git and node.js installed.

Clone a copy of the repository:

$ git clone git@github.com:CODEYA/node-shellscript-ts.git

Change to the shellscript-ts directory:

$ cd node-shellscript-ts

Install dev dependencies:

$ npm install

Build the shellscript-ts:

$ gulp
1.1.1

9 years ago

1.1.0

9 years ago

1.0.13

9 years ago

1.0.12

9 years ago

1.0.11

9 years ago

1.0.10

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago