A helper library for building CLI applications with Commander.
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Go to file
4lch4 1a8f34d337
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details
feat: added @4lch4/logger & inquirer to exported modules
10 months ago
.vscode feat: added .vscode/settings.json 10 months ago
src feat: added @4lch4/logger & inquirer to exported modules 10 months ago
.drone.yml fix(.drone.yml): forgot to update depends_on in publish stage 10 months ago
.gitignore chore: added .vscode/*.log to gitignore 10 months ago
.npmrc feat: added some base files 11 months ago
.nvmrc feat: added some base files 11 months ago
.prettierignore feat: added some base files 11 months ago
.prettierrc feat: added some base files 11 months ago
Makefile chore(Makefile): updated push message 11 months ago
README.md feat: updated README with info on config util classes 11 months ago
package.json 0.7.4 10 months ago
pnpm-lock.yaml chore: updated pnpm-lock 11 months ago
tsconfig.json chore: minor change to tsconfig.json 11 months ago

README.md

Build Status

@4lch4/LT-Commander

LT-Commander is a "helper" library for building CLI applications with Commander.

Config Utilities

LT-Commander exports two configuration utilities, each of which provide a unique set of features/functionality.

ConfigUtil

This class makes use of the configstore dependency. It provides a number of methods for getting, updating, deleting, etc., of configuration settings.

Configstore Details

Easily load and persist config without having to think about where and how.

The config is stored in a JSON file located in $XDG_CONFIG_HOME or ~/.config.

Example: ~/.config/configstore/some-id.json

CosmicUtil

This class makes use of the cosmiconfig dependency which only provides a single method for loading the config file content (if it exists): load

Cosmiconfig Details

Cosmiconfig searches for and loads configuration for your program.

It features smart defaults based on conventional expectations in the JavaScript ecosystem. But it's also flexible enough to search wherever you'd like to search, and load whatever you'd like to load.

By default, Cosmiconfig will start where you tell it to start and search up the directory tree for the following:

  • A package.json property
  • A JSON or YAML, extensionless "rc file"
  • An "rc file" with the extensions .json, .yaml, .yml, .js, or .cjs
  • A .config.js or .config.cjs CommonJS module

For example, if your module's name is "myapp", cosmiconfig will search up the directory tree for configuration in the following places:

  • A myapp property in package.json
  • A .myapprc file in JSON or YAML format
  • A .myapprc.json, .myapprc.yaml, .myapprc.yml, .myapprc.js, or .myapprc.cjs file
  • A myapp.config.js or myapp.config.cjs CommonJS module exporting an object

Cosmiconfig continues to search up the directory tree, checking each of these places in each directory, until it finds some acceptable configuration (or hits the home directory). If a path is provided to the load function, then the search begins there.