bedo v0.0.4
Entry Point Script File Executor
The bedo is a script file executor that allows defining entry points in various ways and supports TypeScript. It offers features such as the ability to define loop and main entry points with options for clear screen, limit counts, and delay execution.
Features
- Support Typescript
- Support loop entry point
- Support main entry point
- Support functional or export syntax
Installation
npm :
$ npm install --save-dev bedoyarn :
$ yarn add --dev bedopnpm :
$ pnpm add --save-dev bedoBun :
$ bun add --dev bedoUsage
Bedo accepts entry points in several ways: by defining them directly in the script file or by exporting functions. It supports defining both main and loop entry points.
Defining Entry Points (single-executable):
#!/usr/bin/env -S npx bedox
import { main, loop } from 'bedo';
main((...args: unknown[]) => {
console.log('main - example', args);
});
loop((count: number) => {
console.log('loop - example', count);
}, { limit: 10 });Then, To make the script file executable:
$ sudo chmod +x ./SCRIPT_FILE.tsNext, you can run it with:
$ ./SCRIPT_FILE.tsor pass the flag arguments to it:
$ ./SCRIPT_FILE.ts --helpDefining Entry Points
import { main, loop } from 'bedo';
main((...args) => {
console.log('main - example', args);
});
loop(
(count) => {
console.log('loop - example', count);
},
{ limit: 10 },
);Then, to execute the script file, you can follow one of deno/bun/node (or ts-node/tsx if TypeScript) or bedox itself:
$ bedox ./SCRIPT_FILE.tsExporting Entry Points (single-executable):
#!/usr/bin/env -S npx bedo
export default function main(...args: unknown[]) {
console.log('main - example', args);
}
export const LOOP_LIMIT = 10;
export function loop(count: number) {
console.log('loop - example ', count);
}Make the script file executable:
$ sudo chmod +x ./SCRIPT_FILE.tsNext, run the script:
$ ./SCRIPT_FILE.tsor pass the flag arguments:
$ ./SCRIPT_FILE.ts --helpExporting Entry Points:
export default function main(...args) {
console.log('main - example', args);
}
export const LOOP_LIMIT = 10;
export function loop(count) {
console.log('loop - example ', count);
}Then, to execute the script file, you should run it using the bedo command:
$ bedo ./SCRIPT_FILE.tsAPI Documentation
Bedo provides the following entry points:
main: To execute once in the entire life of the script execution.loop: To execute at every duration or frame per second until the limit count is reached.
Main Entry
To execute once in the entire life of the script execution.
There are two ways to declare the Main Entry Point: export default or functional.
!NOTE Aliases:
main,initandsetupin functional mode
- Functional Mode:
| Options | Type | Default value | Description |
|---|---|---|---|
clear_screen | boolean? | false | clear the terminal before executing the main entry point once |
- Callback Parameter:
| Parameters | Type | Description |
|---|---|---|
...args | unknown[] | will pass process.argv.slice(2) or similar |
Loop Entry
To execute at every duration or frame per second (frame / 1000) until the limit count is reached.
There are two ways to declare the Loop Entry Point: export loop or functional.
!NOTE Aliases:
loop,updateandtickin functional mode
- Functional Mode:
| Options | Type | Default value | Description |
|---|---|---|---|
clear_screen | boolean? | false | clear screen before each execution of loop entry |
duration | number? | - | delay between each execution of loop entry. |
frame | number? | 30 | how many frame per seconds can run. |
limit | number? | Number.Infinity | define limit to how many loop can be run |
- Exporting Mode:
| Options | Type | Default value | Description |
|---|---|---|---|
LOOP_CLEAR_SCREEN | boolean? | false | clear screen before each execution of loop entry |
LOOP_DURATION | number? | - | delay between each execution of loop entry. |
LOOP_FRAME | number? | 30 | how many frame per seconds can run. |
LOOP_LIMIT | number? | Number.Infinity | define limit to how many loop can be run |
if use
duration, it's overrideframevalue
- Callback Parameter:
| Parameters | Type | Description |
|---|---|---|
count | number | will cache count of each execution ticks |
LICENSE
Under GPLv3 for Open Source by Wonize Group.
1 year ago
