Skip to content

Commit

Permalink
Add support to specify league ⭐ ⚽
Browse files Browse the repository at this point in the history
  • Loading branch information
krolow committed Sep 20, 2016
1 parent ce81700 commit 3c5534a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ It's a simple CLI that display the current [brasileirão table](http://globoespo
### Usage

```bash
$ ./tabela-brasileirao
$ ./tabela-brasileirao b
★ BRASILERÃO SÉRIE B ⚽
+-----+-------------------+----+----+----+----+----+----+----+-----+------+
| POS | TIME | P | J | V | E | D | GP | GC | SG | % |
+-----+-------------------+----+----+----+----+----+----+----+-----+------+
Expand Down
11 changes: 10 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package main

import (
"fmt"
"log"
"os"
"reflect"
"strconv"
"strings"

"github.com/PuerkitoBio/goquery"
"github.com/olekukonko/tablewriter"
Expand All @@ -25,7 +27,13 @@ type Team struct {
}

func main() {
doc, err := goquery.NewDocument("http://globoesporte.globo.com/futebol/brasileirao-serie-b/")
league := "a"

if len(os.Args) > 1 && os.Args[1] == "b" {
league = "b"
}

doc, err := goquery.NewDocument("http://globoesporte.globo.com/futebol/brasileirao-serie-" + league + "/")

if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -53,6 +61,7 @@ func main() {
})

table := tablewriter.NewWriter(os.Stdout)
fmt.Println("\u2605 BRASILERÃO SÉRIE " + strings.ToUpper(league) + " \u26BD")
table.SetHeader([]string{"Pos", "Time", "P", "J", "V", "E", "D", "GP", "GC", "SG", "%"})

for _, team := range teams {
Expand Down

0 comments on commit 3c5534a

Please sign in to comment.