Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@interactive-cli-helper/file-suggestor

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@interactive-cli-helper/file-suggestor

Allow to auto-suggest one file name as a command suggestion for [interactive-cli-helper package](https://www.npmjs.com/package/interactive-cli-helper).

  • 1.0.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

interactive-cli-helper / file suggestor

Allow to auto-suggest one file name as a command suggestion for interactive-cli-helper package.

Getting started

npm i @interactive-cli-helper/file-suggestor

Usage

Give the default export of package as onSuggest value in command options.

With functional API

import CliHelper from 'interactive-cli-helper';
import cliFileSuggestor from '@interactive-cli-helper/file-suggestor';
import fs from 'fs';

// Assuming cli is a CliHelper/CliListener instance

// Declare it
cli.command('read', filename => {
  console.log(fs.readFileSync(filename, 'utf-8'));
}, {
  onSuggest: cliFileSuggestor,
});

cli.listen();

With decorators API

import { CliMain, CliBase, Command, CliCommand, CliCommandInstance, CliExecutor } from 'interactive-cli-helper';
  
@CliCommand()
class ReadCommand {
  onSuggest = cliFileSuggestor;
  
  executor: CliExecutor = filename => {
    console.log(fs.readFileSync(filename, 'utf-8'));
  };
}
 
@CliMain({ suggestions: true })
class Main extends CliBase {
  onNoMatch: CliExecutor = 'No command matched your search.';
 
  // Assign ReadCommand for 'read' command
  @Command('read', ReadCommand)
  read_command!: CliCommandInstance<ReadCommand>;
}
 
const cli = new Main();
cli.listen();

Keywords

FAQs

Package last updated on 26 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc