Skip to content

Commit 36263e0

Browse files
committed
Merge branch 'master' of github.com:dherbst/septa
2 parents ec33dd2 + 078d8c2 commit 36263e0

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ You can create a bash alias to make looking up the next to arrive for your favor
77

88
alias nta="septa next Narberth \"Suburban Station\""
99

10+
Alternatively, you can use the `go install` command, if you clone this repo to your implied `GOPATH`.
11+
1012

1113
## Commands
1214

@@ -23,7 +25,16 @@ Returns the next to arrive between the src and dest stations.
2325

2426

2527
### septa stations
26-
TODO: Will list the stations.
28+
Returns the list of stations
29+
30+
$ septa stations
31+
32+
9th St
33+
30th Street Station
34+
49th St
35+
Airport Terminal A
36+
Airport Terminal B
37+
...
2738

2839

2940
### Alerts

cmd/septa/septa.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ var funcMap map[string]func(context.Context)
1212

1313
func init() {
1414
funcMap = map[string]func(context.Context){
15-
"help": Usage,
16-
"next": NextToArrive,
17-
"version": Version,
15+
"help": Usage,
16+
"next": NextToArrive,
17+
"stations": Stations,
18+
"version": Version,
1819
}
1920
}
2021

@@ -28,8 +29,9 @@ func Usage(ctx context.Context) {
2829
fmt.Printf(`
2930
Usage:
3031
31-
septa next [from-station] [to-station]
32-
septa version ; prints the commit version
32+
septa stations [pattern] ; list stations, or match pattern
33+
septa next [from-station] [to-station] ; show the next to arrive
34+
septa version ; prints the commit version
3335
`)
3436

3537
}

cmd/septa/station.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/dherbst/septa"
8+
)
9+
10+
// Stations command lists the stations that acceptable for Next To Arrive.
11+
func Stations(ctx context.Context) {
12+
for _, v := range septa.Stations {
13+
fmt.Printf("%v\n", v)
14+
}
15+
}

station.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package septa
22

3-
var stations = []string{
3+
// Stations is the list of valid station names for next to arrive
4+
var Stations = []string{
45
"9th St",
56
"30th Street Station",
67
"49th St",
@@ -160,7 +161,7 @@ var stations = []string{
160161

161162
// IsValidStation returns whether the station is a valid station.
162163
func IsValidStation(station string) bool {
163-
for _, v := range stations {
164+
for _, v := range Stations {
164165
if station == v {
165166
return true
166167
}

0 commit comments

Comments
 (0)