GithubHelp home page GithubHelp logo

kylebanks / commuter Goto Github PK

View Code? Open in Web Editor NEW
20.0 4.0 4.0 1.07 MB

Commute times on the command line!

Home Page: https://kylewbanks.com/blog/introducing-commuter-commute-times-on-command-line

License: MIT License

Go 99.15% Makefile 0.85%
commute commuting drivers driving transit transportation google-maps commute-times command-line-app

commuter's Introduction

Commuter

Build Status   GoDoc   Go Report Card   Coverage Status

Get commute times on the command line!

  • Get commuting time between locations.
  • Name and add your frequent locations for easier access.
  • Geolocation allows you to use your current location without typing an address.

Install

Download the appropriate commuter binary from the Releases page.

Alternatively, if you have a working Go installation, you can install commuter like so:

$ go get github.com/KyleBanks/commuter

Usage

The first time you run commuter, you'll be prompted to provide a Google Maps API Key and default location.

Important: Ensure you enable the Google Maps Distance Matrix API at developers.google.com/console. If you want to use the -from-current and -to-current flags, you will also need to enable the Google Maps Geolocation API.

$ commuter
> Enter Google Maps API Key: (developers.google.com/console)
123APIKEY456
> Enter Your Default Location: (ex. 123 Main St. Toronto, Canada)
123 Main St. Toronto, Ontario

The API key and default location will be stored locally, and are never sent to any remote services aside from the official Google Maps API. The default location is then used by default when a -from or -to location is not provided.

Next, request your commute time:

# From your default to a specific location:
$ commuter -to "321 Maple Ave. Toronto, Ontario"
32 Minutes

# From a specific location to your default:
$ commuter -from "Toronto, Ontario"
20 Minutes

If you want a commute time beginning and ending somewhere other than your default location, you can use supply full locations for both the -from and -to flags:

$ commuter -from "123 Main St. Toronto, Ontario" -to "321 Maple Ave. Toronto, Ontario"
32 Minutes

commuter add

You can also add names for your frequent locations like so:

$ commuter add -name home -location "123 Main St. Toronto, Ontario"
$ commuter add -name work -address "321 Maple Ave. Toronto, Ontario"

And use them as the from and/or to location:

$ commuter -from home -to work
32 Minutes

commuter list

To see a list of all your named locations:

$ commuter list
default: 123 Main St. Toronto, Ontario
    gym: 1024 Fitness Lane Toronto, Ontario
   work: 321 Maple Ave. Toronto, Ontario

Using Your Current Location

If you enabled the Google Maps Geolocation API for your API key, you can use the -from-current and -to-current flags to use your current location. This is done by attempting to use your IP Address to determine your latitude and longitude, and use that as either the start or destination of your commute:

$ commuter -from-current -to work
32 Minutes
$ commuter -from gym -to-current
12 Minutes

Travel Modes

By default, commuter assumes you are driving between locations. However, you can specify one or more commute methods using the -drive, -walk, -bike and -transit flags, like so:

# Single mode:
$ commuter -walk -to work
7 Hours 50 Minutes

# Multiple modes:
$ commuter -walk -transit -drive -bike -to work
Drive: 30 Minutes
Walk: 7 Hours 50 Minutes
Bike: 2 Hours 45 Minutes
Transit: 1 Hour 17 Minutes

And of course the different travel modes can be combined with your current location:

$ commuter -bike -from-current -to gym
2 Hours 18 Minutes

License

MIT License

Copyright (c) 2017 Kyle Banks

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

commuter's People

Contributors

kylebanks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

commuter's Issues

Add geolocation for the 'from address'

Add a flag to attempt to use the users current location as the 'from' address.

Ex:

commuter -from-current -to work

This would attempt to determine the users current location and use that as the from address.

Prompt to configure on first use

Regardless of the command, if any, commuter should prompt the user for API key and default location if there is no existing configuration.

Ability to add named locations

This would allow you to save an address, similar to the default, and use it as an address in other commands.

Ex:

commuter add -name home -value "123 Main st."
commuter -to home

The second command would print the commute from default to home.

[BUG] README instructions fail

Instructions in the README say to use:

$ commuter add -name work -address "321 Maple Ave. Toronto, Ontario"

However, the -address command is not recognized and returns the error:

flag provided but not defined: -address

It should be -location

Ability to monitor a commute

Would be nice to be able to monitor a commute, and optionally write the output to a file. By default, monitor would poll every minute, and the user could supply their own interval (in minutes).

Ex:

commuter monitor --from home --to work

Would print the commute time to stdout every minute.

commuter monitor --from home --to work --interval 5 --out file.txt

Would write the commute every five minutes to file.txt.

how to specify route?

Thank you for this software. It is quite ingeneous. Is there a way to specify route? There are two main routes between my home and work, and I'd like to get the commute time for each route so that I can compare.

[Background: I'm trying to create a cron job that will run every morning, get the commute time for each route, then send me a text message advising which of the two routes is best.]

Does not write configuration file

I've installed both the binary, and from within GO, in Ubuntu and both will always ask for the google maps API key and home location, and seem unable to store them. I haven't been able to figure out how to debug the issue commuter is having storing the data, and as such it is not currently usable.

Ability to specify a commute method

This would allow you to get commute times for other methods of transportation:

commuter -to work -drive
commuter -to work -transit
commuter -to work -walk
commuter -to work -bike

Specifying multiple commands would display the commute time for each:

commuter -to work -drive -transit
Drive: 45 mins
Transit: 37 mins

-all-methods could also be used to specify that all transit types should be used.

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.