Code Monkey home page Code Monkey logo

aqi's Introduction

aqi

一个命令行查询实时空气质量指数的工具,使用Go开发,数据来自 Real-time Air Quality Index

screenshot1

screenshot2

安装:

$ go get -u github.com/wangrenjun/aqi

墙内用户(Go 1.13及以上):

GO111MODULE=on GOPROXY=https://goproxy.cn go get -u github.com/wangrenjun/aqi

快速使用:

查询本地天气(IP地址定位):

$ ${GOPATH}/bin/aqi -t <TOKEN>

查询某城市的空气指数:

$ ${GOPATH}/bin/aqi -t <TOKEN> -c beijing

查询多个城市的空气指数:

$ ${GOPATH}/bin/aqi -t <TOKEN> -c beijing,shanghai -c guangzhou,shenzhen,hangzhou

查询某城市的所有监测站点的空气指数:

$ ${GOPATH}/bin/aqi -t <TOKEN> -s beijing

查询多个城市的所有监测站点的空气指数:

$ ${GOPATH}/bin/aqi -t <TOKEN> -s beijing,shanghai,guangzhou

以中文显示查询结果:

$ ${GOPATH}/bin/aqi -t <TOKEN> -c beijing,shanghai -c guangzhou,shenzhen,hangzhou -z
$ ${GOPATH}/bin/aqi -t <TOKEN> -s beijing,shanghai,guangzhou -z

命令选项:

Usage of aqi:
    -c value
            Comma-separated list of cities.
    -city value
            Comma-separated list of cities.
    -s value
            Comma-separated list of keywords.
    -search value
            Comma-separated list of keywords.
    -t string
            API token.
    -token string
            API token.
    -z      中文显示
    -zhcn
            中文显示

关于Token的申请:

因为数据来自 Real-time Air Quality Index,所以使用前需要到这里申请Token。

配置文件:

配置文件的默认路径是 $HOME/.aqirc,文件类型为Toml,配置好了之后就不需要每次输入参数,可配置的选项有:

  • zhcn bool值,是否以中文显示;
  • cities 数组值,需要查询的城市名称(拼音);
  • keywords 数组值,需要查询监测站点的城市名称(拼音);
  • token string值,就是Token;

一个配置例子:

zhcn = false
cities = [ "beijing", "shanghai", "dalian" ]
keywords = [ "beijing", "guangzhou" ]
token = "demo"

结语:

因为服务在墙外,所以在未使用科学上网的情况下,偶尔会不稳定,但是总体上还是能够使用的。

aqi's People

Contributors

wangrenjun avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

aqi's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.