relekang / cli-editor

A wrapper around the default terminal editor that can edit any object.

Home Page:https://www.npmjs.com/package/@relekang/cli-editor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cli-editor

This is a simple editor that can be used to edit javascript objects with the current editor in the terminal. The editor is fetched with EDITOR environment variable.

Installation

npm install @relekang/cli-editor

or

yarn add @relekang/cli-editor

Usage

import {edit} from "@relekang/cli-editor"

edit({
    fetch: async function() { return getItem() },
    save: async function(item) { return saveItem(item) },
    errorHandler: function (error) {
        return {retry: true, message: "Could not save due to " + error.toString()}
    },
})
.catch(error => console.error("ooops", error))

About

A wrapper around the default terminal editor that can edit any object.

https://www.npmjs.com/package/@relekang/cli-editor

License:MIT License


Languages

Language:JavaScript 100.0%