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

owm-cli

v0.0.1

Published

Display weather info for a city from OpenWeatherMap API

Downloads

5

Readme

OpenWeatherMap CLI

Build Status codecov Known Vulnerabilities Maintainability

Display weather info for a city from OpenWeatherMap API, interactively, from command line or from a config.

example

Usage

Make sure you have OPENWEATHERMAP_API_KEY in env when running this app. Get it at openweathermap.org. For convenience, alias yarn start or node bin/index.js to openweathermap-cli, exact steps are at the bottom of this README.

Examples:

  • openweathermap-cli # no args - will ask interactively for a location with detected current city
  • openweathermap-cli -c Paris - will provide info for Paris in °C (default)
  • openweathermap-cli --city Prague -scale fahrenheit - will provide info for Prague in °F
  • openweathermap-cli -l - will repeat the latest query
  • openweathermap-cli -i locations.txt - will provide info for locations from a text file
  • openweathermap-cli --disable-geolocation - will ask interactively without asking for a location

Options

Options:
  -c, --city                 Specify the city                           [string]
  -z, --zip                  Specify the zip code                       [string]
  -l, --latest-query         Use latest query                          [boolean]
  -s, --scale                Define a scale to use [string] [default: "celsius"]
  -g, --disable-geolocation  Disable geolocation (enabled by default)
                                                      [boolean] [default: false]
  -i, --import               Import a file with multiple locations      [string]
  -v, --version              Show version number                       [boolean]
  -h, --help                 Show help                                 [boolean]

Multiple locations config file

Specify up to 10 different cities or zip codes from a file (e.g. locations.txt), each on a separate line, and import with -i flag.

Paris
Barcelona
Prague

Stack

  • Node.js (v12 LTS), Yarn, Babel, Flow
  • ESlint, Prettier
  • Jest, Chai, Sinon
  • Got (requirement, used for API fetching)
  • Yargs (great time saver when parsing CLI args)

Possible improvements

  • better UX (not a CLI in the ideal scenario, who looks for the weather in CLI?)
  • better API (this one is slow and limited, we should create our own and connect to different providers maybe)
  • better error handling, error messages, retrying, any maybe caching
  • dependency injection mechanism for clearer classes and better testing
  • debug / log messages (if specified from command line)
  • CliParser class could be refactored into smaller pieces and tested more thoroughly
  • integration tests

Development

  1. Clone and install
git clone https://github.com/jakubzitny/openweathermap-cli
cd openweathermap-cli
yarn
  1. Build it
yarn build
  1. Check and test
yarn flow
yarn prettier
yarn lint
yarn test
  1. Run
yarn start --help

yarn start
yarn start -c Prague

# or with alias
alias openweathermap-cli="node bin/index.js"

openweathermap-cli --help
openweathermap-cli -c Prague
openweathermap-cli --city Paris -scale fahrenheit