Skip to content

Commit

Permalink
added versioning and removed "to" operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaya-Sem committed Sep 30, 2024
1 parent 5bff85e commit c87ec56
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Changelog

All notable changes to this project will be documented in this
file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Added

- v1.1 added `commandtrein version` to print software version
- v1.0 added versioning

### Changed

- v1.0 Changed dropped the "to" operator in CLI usage

### Fixed


14 changes: 11 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,28 @@ import (
teaTable "github.com/charmbracelet/bubbles/table"
)

const Version = "1.1.0"

func main() {
// TODO: allow flags for time and arrdep
args := cmd.ShiftArgs(os.Args)

if len(args) == 1 {
if args[0] == "search" {
handleSearch()
} else if args[0] == "version" {
handleVersion()
} else {
handleTimetable(args[0])
}

} else if len(args) == 3 {
handleConnection(args[0], args[2])
} else if len(args) == 2 {
handleConnection(args[0], args[1])
}
}

func handleConnection(stationFrom string, stationTo string) {
s := cmd.NewSpinner("", " fetching connections...", 1*time.Second)
s := cmd.NewSpinner("", " fetching connections", 1*time.Second)
s.Start()

connectionsJSON, err := api.GetConnections(stationFrom, stationTo)
Expand Down Expand Up @@ -126,3 +130,7 @@ func handleTimetable(stationName string) {

table.RenderTable(columns, rows, departures)
}

func handleVersion() {
fmt.Printf("commandtrein %s\n", Version)
}

0 comments on commit c87ec56

Please sign in to comment.