Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vilicvane/main-function
A simple wrapper that handles error and return code.
https://github.com/vilicvane/main-function
Last synced: 20 days ago
JSON representation
A simple wrapper that handles error and return code.
- Host: GitHub
- URL: https://github.com/vilicvane/main-function
- Owner: vilicvane
- License: mit
- Created: 2019-03-10T15:53:02.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-03T11:17:49.000Z (about 1 year ago)
- Last Synced: 2024-11-30T15:41:56.983Z (23 days ago)
- Language: TypeScript
- Size: 220 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![NPM Package](https://badge.fury.io/js/main-function.svg)](https://www.npmjs.com/package/main-function)
[![Build Status](https://travis-ci.org/vilic/main-function.svg?branch=master)](https://travis-ci.org/vilic/main-function)# Main Function
A simple wrapper that handles error and return code.
## Install
```sh
yarn add main-function
```## Usage
```ts
import main, {ProgramError} from 'main-function';main(async (args: string[]) => {
// Throw an `ProgramError` to exit:
throw new ProgramError(0, 'Some friendly error message');// Or throw a normal error (will print error stack and exit with code `1`):
throw new Error():// Optional return statement for exit code:
return 0;
});
```## License
MIT License.