weather-cli
JS CLI to consume Weather API.
Setup
- Install dependencies
$ npm i
- Copy
.env.example
file into a new one called.env
.
# Unix
$ cp .env.example .env
-
Get an API key from Weather API and write it down in
WEATHER_API_KEY
variable in.env
file. -
Run CLI.
# Directly from file
$ node dist/index.js
# As CLI
# Create symbolic link. This command is just run once.
$ npm link
# After that, you can use CLI as a terminal command.
$ weather-cli
Options
- -c, --city
Set city to look for weather information. Default: Dallas.
$ node dist/index.js -c Mexico City
$ weather-cli --city Mexico City
- -e, --export
Export weather information as a CSV file called
weather.csv
. Default: false.
$ node dist/index.js -e
$ weather-cli --export
- -f, --filename
Name for exported file. Only available when export option is set. Default: weather.csv
$ node dist/index.js -e -f my_custom_name.csv
$ weather-cli --export --filename my_custom_name.csv
- -h, --help
Show CLI help.
$ node dist/index.js -h
$ weather-cli --help
Development
# Watch changes
$ npm run dev
# Test CLI
$ npx ts-node src/index.ts
Production
# Transpile files
$ npm run build
# Test CLI
$ node dist/index.js