From c87ec56e1e50898c3a466c8d60a91a2010363a4b Mon Sep 17 00:00:00 2001 From: Kaya-Sem Date: Mon, 30 Sep 2024 12:00:36 +0200 Subject: [PATCH] added versioning and removed "to" operator --- CHANGELOG.md | 20 ++++++++++++++++++++ main.go | 14 +++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 CHANGELOG.md 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) +}