You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@itsmworkbench/cli

Package Overview
Dependencies
4
Maintainers
0
Versions
85
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@itsmworkbench/cli

How to do a cli


Version published
Weekly downloads
480
decreased by-28.68%
Maintainers
0
Created
Weekly downloads
 

Readme

Source

Overview

This is about the tenth time I have cut and pasted the same thing.

It's time to make a module that can do this for me!

Config file

Most CLIs have some config. Not all but some. This might be

  • Stored in '~/.xxx.json'
  • Stored in the current directory
  • Stored in a parent directory
  • Stored in a directory xx hanging off a parent directory
  • etc... So many options so we abstract it

Observations

  • We need the config before we build the cli because often we use it in the construction of the cli.
  • Often the config needs validating and errors reporting.
  • We will probably need commands to look at the config and validate it for every CLI we build.
  • We need to build the config... we might add things that aren't serializable to it: this is our dependency injection too

Building the CLI

  • We always need --version. It's hard to do that here so pass it in...
  • We need the config before we build the cli
  • We need to be able to add config commands to the cli (but not do it automatically)

finding your version

In your main file. Because of the use of require it's hard to do this in a library.

export function findVersion () {
  let packageJsonFileName = "../package.json";
  try {
    return require ( packageJsonFileName ).version
  } catch ( e ) {
    return "version not known"
  }
}

Keywords

FAQs

Package last updated on 15 Jul 2024

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc