Home Manual Reference Source Test

Programmatic usage

Please note that using the atscm-cli API is an advanced topic.

It's recommended to use the command line interface whenever possible.

ES6 JavaScript

The code provided in this document is written in ES2015 JavaScript.

You will have to transpile it (e.g with Babel) in order to get it running.

Creating a Cli instance

Basically, the AtSCMCli class can be used just like any other class:

import AtSCMCli from 'atscm-cli';

const cli = new AtSCMCli();

As stated in the API reference the constructor takes any arguments the command line interface can handle. E.g. running

import AtSCMCli from 'atscm-cli';

const cli = new AtSCMCli(['--version']);
cli.launch();

will print the version, just as if we ran the atscm-cli from the command line.

The main difference between API and command line usage is, that exceptions are not handled. You'll have to do that yourself:

import AtSCMCli from 'atscm-cli';

new AtSCMCli(['--version'])
  .launch() // Note: AtSCMCli#launch returns a Promise
  .then(() => console.log('success!'))
  .catch((err) => console.error(`Oops! An error occured: ${err.message}`));

Please refer to AtSCMCli's class reference in order to see all methods and properties available.