@hailer/cli

中文文档
1.2.3发布于 2026/10/09ISCTypeScriptCommonJS近 30 天下载 5.1万

Hailer CLI

原始使用文档
文档目录7 节
  1. Usage as Cli
  2. Install
  3. Example usage
  4. Programmatic Usage
  5. Login with username and password
  6. Inside async function
  7. Hailer API documentation

Hailer CLI

A Command Line interface to Hailer. It can also be used to programmatically access Hailer.

Usage as Cli

All backend Socket API commands are available in the CLI.

Tab completion is available.

The result of each command is stored in the result variable.

Install

npm install -g @hailer/cli

Usage:

hailer-cli --user [email protected]

Example usage

Example usage:

await api.wall2.new_post({ subject: 'This is a wall post.', text: 'Look, this is a cool wallpost made from the Cli.' })
await api.wall2.remove_post(result._id)

Programmatic Usage

Login with username and password

This example creates a wall post in Hailer, and then removes it after five seconds, and exits.

Create a new nodejs project (npm init) or use an existing. Add hailer-cli as a dependency, using npm install @hailer/cli

mkdir my-hailer-app
cd my-hailer-app
npm init
npm install @hailer/cli

Create a new file run.js and paste the following code (and works with typescript using the import line):

// import { Client } from '@hailer/cli'; // Use with typescript
const { Client } = require('@hailer/cli');

const options = {
    host: 'https://api.hailer.com',
    username: 'set-this',
    password: 'set-this',
};

Client.create(options).then(async (client) => {
    // Listen to signals from Hailer
    client.on('signals', ([name, meta]) => {
        // print all signals
        console.log('Signal:', name, meta);
    });

    // Make API request to create a new feed (wall) post.
    const post = await client.request('wall2.new_post', [{ subject: 'This is a wall post.', text: 'The content of my post' }]);

    console.log('Post created:', post);
    // client.disconnect();
}).catch(error => {
    console.log('Error:', error);
    process.exit(1);
});

Set the username and password parameters to a valid Hailer account.

Log in to Hailer using the browser and go to the Feed to see the script in action.

Start the program:

node run.js

Inside async function

// import { Client } from '@hailer/cli';
const { Client } = require('@hailer/cli');

// ...

const options = {
    host: 'https://api.hailer.com',
    username: 'set-this',
    password: 'set-this',
};

const client = await Client.create(options).catch(error => { console.log('Error:', error); process.exit(1); });

// Listen to signals from Hailer
client.on('signals', ([name, meta]) => {
    // print all signals
    console.log('Signal:', name, meta);
});

const post = await client.request('wall2.new_post', [{ subject: 'This is a wall post.', text: 'The content of my post' }]);

console.log('Post created:', post);

client.disconnect();

Hailer API documentation

To find out what you can do with the Hailer API, visit:

https://api.hailer.com/apidocs

版本与发布记录

@hailer/cli 共发布 8 个版本,首次发布于 2023/08/10;过去 12 个月发布了 4 个版本。

版本发布日期距今
1.2.3latest2026/10/091 个月前
1.2.22026/10/091 个月前
1.2.12026/05/245 个月前
1.2.02026/02/178 个月前
1.1.102025/06/161.4 年前
1.1.92025/06/161.4 年前

关于 @hailer/cli 的常见问题

@hailer/cli 是什么?

Hailer CLI

如何安装 @hailer/cli?

在项目目录运行 npm install @hailer/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 hailer-cli,可以用 npx hailer-cli 直接运行。

@hailer/cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@hailer/cli 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@hailer/cli 可以商用吗?

@hailer/cli 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@hailer/cli 的下载量有多少?

根据 npm 官方下载统计,@hailer/cli 在 2026/10/17 – 2026/11/15 这 30 天内被下载 51,226 次,日均约 1,708 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@hailer/cli 还在维护吗?

最新版本 1.2.3 发布于 2026/10/09(1 个月前);至今共发布 8 个版本,其中过去 12 个月发布了 4 个;首次发布于 2023/08/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。