diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..308c50a --- /dev/null +++ b/CHANGELOG.md @@ -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 + + diff --git a/main.go b/main.go index 3dc2ef9..ef3c1df 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,8 @@ 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) @@ -19,17 +21,19 @@ func main() { 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) @@ -126,3 +130,7 @@ func handleTimetable(stationName string) { table.RenderTable(columns, rows, departures) } + +func handleVersion() { + fmt.Printf("commandtrein %s\n", Version) +}