Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/umayr/calver
small utility to handle Calendar Versioning (https://calver.org/)
https://github.com/umayr/calver
calver cli golang
Last synced: about 15 hours ago
JSON representation
small utility to handle Calendar Versioning (https://calver.org/)
- Host: GitHub
- URL: https://github.com/umayr/calver
- Owner: umayr
- License: mit
- Created: 2020-12-20T08:28:10.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-21T05:54:17.000Z (almost 4 years ago)
- Last Synced: 2024-03-14T16:48:10.632Z (8 months ago)
- Topics: calver, cli, golang
- Language: Go
- Homepage:
- Size: 57.6 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CalVer
> small utility to handle Calendar Versioning (https://calver.org/)# Usage
### API
```go
import (
"fmt"
"github.com/umayr/calver"
)func main() {
c, err := calver.New("YYYY.MM.DD", "dev")
if err != nil {
panic(err)
}
fmt.Println(c) // YYYY.MM.DD
r := c.Release()
fmt.Println(r) // 2020.12.20
r = c.PreRelease()
fmt.Println(r) // 2020.12.20-dev.1
r = c.PreRelease()
fmt.Println(r) // 2020.12.20-dev.2
r = c.Release()
fmt.Println(r) // 2020.12.20-2
// different day
r = c.Release()
fmt.Println(r) // 2020.12.21
p, err := calver.Parse("2020.12.20-dev.2", "YYYY.MM.DD", "dev")
if err != nil {
panic(err)
}
fmt.Println(p.PreRelease()) // 2020.12.20-dev.3
fmt.Println(p.Release()) // 2020.12.20-3
}```
Available segments:
```go
const (
FullYear = "YYYY"
ShortYear = "YY"
PaddedYear = "0Y"
ShortMonth = "MM"
PaddedMonth = "0M"
ShortWeek = "WW"
PaddedWeek = "0W"
ShortDay = "DD"
PaddedDay = "0D"
)
```You can build any format using these segments, one thing to note that you need to have at lease two parts `major` and `minor` (for instance `YYYY.0W`) for a format to be valid, at max you have three segments (`major`, `minor` and `micro`)
### CLI
```bash
# install it using go
λ go get github.com/umayr/calver/cmd/calver# build it from source
λ git clone https://github.com/umayr/calver
λ cd calver
λ makeλ calver --help
calver is a small utility to handle calender versioning:Usage of calver:
-format string
format to parse the provided version (default "YYYY.MM.DD")
-modifier string
modifier for prerelease versions (default "dev")
-pre-release
flag to create a prereleaseFor more information on Calender Versioning: https://calver.org
λ calver 2019.1.1
2020.12.20λ calver --pre-release 2019.1.1
2020.12.20-devλ calver 2020.12.20-dev
2020.12.20
```