0.0.4 • Published 1 year ago

bedo v0.0.4

Weekly downloads
-
License
GPL-3.0-only
Repository
github
Last release
1 year ago

BANNER

Entry Point Script File Executor

version MIT License

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 Yarn pnpm bun deno

npm :

$ npm install --save-dev bedo

yarn :

$ yarn add --dev bedo

pnpm :

$ pnpm add --save-dev bedo

Bun :

$ bun add --dev bedo

Usage

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.ts

Next, you can run it with:

$ ./SCRIPT_FILE.ts

or pass the flag arguments to it:

$ ./SCRIPT_FILE.ts --help

Defining 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.ts

Exporting 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.ts

Next, run the script:

$ ./SCRIPT_FILE.ts

or pass the flag arguments:

$ ./SCRIPT_FILE.ts --help

Exporting 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.ts

API 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, init and setup in functional mode

  • Functional Mode:
OptionsTypeDefault valueDescription
clear_screenboolean?falseclear the terminal before executing the main entry point once
  • Callback Parameter:
ParametersTypeDescription
...argsunknown[]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, update and tick in functional mode

  • Functional Mode:
OptionsTypeDefault valueDescription
clear_screenboolean?falseclear screen before each execution of loop entry
durationnumber?-delay between each execution of loop entry.
framenumber?30how many frame per seconds can run.
limitnumber?Number.Infinitydefine limit to how many loop can be run
  • Exporting Mode:
OptionsTypeDefault valueDescription
LOOP_CLEAR_SCREENboolean?falseclear screen before each execution of loop entry
LOOP_DURATIONnumber?-delay between each execution of loop entry.
LOOP_FRAMEnumber?30how many frame per seconds can run.
LOOP_LIMITnumber?Number.Infinitydefine limit to how many loop can be run

NOTE if use duration, it's override frame value

  • Callback Parameter:
ParametersTypeDescription
countnumberwill cache count of each execution ticks

LICENSE

Under GPLv3 for Open Source by Wonize Group.

0.0.4

1 year ago