Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
ndr-power edited this page Jan 8, 2018 · 3 revisions

Russian

Простое приложение

Сейчас мы рассмотрим пример простого приложения для JsOS (appman)

Hello world приложение представляет из себя файл index.js в папке helloworld. Вот его содержимое:

// Example application for JsOS
'use strict';
function main(cmd, args, api, res) {
 const io = api.stdio; // Короткое имя
 io.setColor('green'); // Устанавливаем зеленый цвет текста
 io.writeLine('Hello World!!!'); // Выводим на экран текст: Hello World!!!
 io.writeLine(`Command: ${cmd}; Args: ${args}`); // Command: helloworld; Args:
 return res(0); // Завершаем программу (0 - всё нормально, 1 - ошибка)
}
exports.call = main;
exports.commands = ['helloworld'];

Параметры

appman использует параметр commands для регистрации команд запуска (В данном случае, для запуска нужно ввести: start helloworld)

Методы

appman при запуске приложения вызывает метод call с такими аргументами:

  • cmd {string} - Команда (полезно, если вы указали в exports.commands несколько команд)
  • args {string} - Аргументы (текст после команды)
  • api {object} - API приложения
  • res {function} - Callback для завершения программы

English

Simple Application

Hello world application is index.js file in helloworld dir. Its contents:

// Example application for JsOS
'use strict';
function main(cmd, args, api, res) {
 const io = api.stdio; // short name
 io.setColor('green'); // set font color to green
 io.writeLine('Hello World!!!'); // display "Hello World!!!" on the screen
 io.writeLine(`Command: ${cmd}; Args: ${args}`); // Command: helloworld; Args:
 return res(0); // Finish execution (0 - OK, 1 - ERR)
}
exports.call = main;
exports.commands = ['helloworld'];

Parameters

appman uses commands parameter to register execution commands (i.e. you should type following command to run the program : start helloworld)

Methods

appman calls call method on execution with theese aruments:

  • cmd {string} - Command (useful if you defined more than one command in exports.commands )
  • args {string} - Arguments (text after the command)
  • api {object} - App API
  • res {function} - Callback for program to stop
Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /