npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

config-or-ask

v1.1.2

Published

CLI that stores values in a config and can be called in bash scripts. If the value is not in the config, then it'll look in your environment variables and if it's not there, it'll ask the user for input. It's a form of caching information for use in bash

Downloads

5

Readme

config-or-ask

This is a CLI that helps you get values in your bash scripts. The way it works is that it looks to see if the variable name you're looking for is in a file or in the environment and if it is there then it returns that value. If the value is not there, then it asks the user for input and then stores that for future use.

oclif Version CircleCI Downloads/week License

Quick Installation

npm install -g config-or-ask

Full Installation

In order to provide this CLI to all users, we'll want to install it from the binaries provided. Download the .tar.gz file from the releases page.

Then run the following to install:

tar -xvf config-or-ask-<version>.tar.gz
sudo rm -rf /usr/local/src/config-or-ask
sudo rm -rf /usr/local/bin/config-or-ask
sudo mv config-or-ask /usr/local/src/config-or-ask
sudo ln -s /usr/local/src/config-or-ask/bin/config-or-ask /usr/local/bin/config-or-ask

Usage

The idea for this CLI is that you use it in a bash script to retrieve values from a cache if you have it or from user input if you don't. Examples may include:

USERNAME=$(config-or-ask get MY_APP_USERNAME)
# This will check if the variable MY_APP_USERNAME exists 
# in the config or in the environment. If it is not there 
# it will ask the user to input a value for it. Let's say
# that the value wasn't there and the user enters "bob".
echo ${USERNAME} 
# Output: bob

# You can also have custom config locations. For example
# you may wan't project level configs. In that case, you
# can use the --config flag to specify a config file.
USERNAME=$(config-or-ask get MY_APP_USERNAME --config=./path/to/my/config.json)
# It will automatically create that folder path and
# config file if it doesn't exist.


# Finally, there may be times when you don't want to
# use the environment variables. In that case you
# can use the --skip-env flag.
USERNAME=$(config-or-ask get MY_APP_USERNAME --skip-env)

Here's how you use the CLI:

$ npm install -g config-or-ask
$ config-or-ask COMMAND
running command...
$ config-or-ask (--version)
config-or-ask/1.1.2 linux-x64 node-v16.15.0
$ config-or-ask --help [COMMAND]
USAGE
  $ config-or-ask COMMAND
...

Commands

config-or-ask delete VARIABLE

Adds the ability to delete a variable from the config

USAGE
  $ config-or-ask delete [VARIABLE] [-p <value>]

ARGUMENTS
  VARIABLE  The name of the variable you would like to get

FLAGS
  -p, --config=<value>  Path to config file (not required, we use one from your local home directory if you do not
                        specify one)

DESCRIPTION
  Adds the ability to delete a variable from the config

EXAMPLES
  $ config-or-ask delete

See code: dist/commands/delete.ts

config-or-ask get VARIABLE

Gets the variable you are looking for from the config file or environment. If it cannot find a value, it asks you for it. You're able to disable the environment or config files if you don't want it to use those.

USAGE
  $ config-or-ask get [VARIABLE] [-e] [-c] [-p <value>]

ARGUMENTS
  VARIABLE  The name of the variable you would like to get

FLAGS
  -c, --skip-config     Don't look at config file for the value
  -e, --skip-env        Don't look at environment variables for the value
  -p, --config=<value>  Path to config file (not required, we use one from your local home directory if you do not
                        specify one)

DESCRIPTION
  Gets the variable you are looking for from the config file or environment. If it cannot find a value, it asks you for
  it. You're able to disable the environment or config files if you don't want it to use those.

  If the config does not exist, it will create it for you.

  The order of importance is:

  1. Config file
  2. Environment variable
  3. User input

EXAMPLES
  $ config-or-ask get MY_VARIABLE_NAME

  $ config-or-ask get MY_VARIABLE_NAME --skip-env

  $ config-or-ask get MY_VARIABLE_NAME --skip-config

  $ config-or-ask get MY_VARIABLE_NAME --config=./path/to/config.json

  MY_VARIABLE_NAME=$(config-or-ask get MY_VARIABLE_NAME)

See code: dist/commands/get.ts

config-or-ask help [COMMAND]

Display help for config-or-ask.

USAGE
  $ config-or-ask help [COMMAND] [-n]

ARGUMENTS
  COMMAND  Command to show help for.

FLAGS
  -n, --nested-commands  Include all nested commands in the output.

DESCRIPTION
  Display help for config-or-ask.

See code: @oclif/plugin-help