@hailer/cli
v1.1.8
Published
Hailer CLI
Downloads
274
Readme
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) => {
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();
});
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);
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();