Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Implement version flag #1

Merged
merged 3 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
go-version-file: 'go.mod'
cache-dependency-path: 'go.sum'
- run: go build -v
- run: go build -v -race
lint:
runs-on: ubuntu-latest
steps:
Expand Down
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# How to develop

## Setup

1. Install [Nix](https://nixos.org/) package manager
2. Run `nix-shell` or `nix-shell --command 'zsh'`
3. You can use development tools

```console
> nix-shell
(prepared bash)

> go version
go version go1.20.4 linux/amd64

> dprint --version
dprint 0.36.1

> go build -ldflags "-X main.revision=$(git rev-parse --short HEAD)"
```
14 changes: 14 additions & 0 deletions nix-headbump.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@ package main

import (
"encoding/json"
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
"regexp"
)

const version string = "0.1.0"

var revision string

func main() {
versionFlag := flag.Bool("version", false, "print the version of this program")
flag.Parse()

if *versionFlag {
fmt.Printf("%s\n", version+"("+revision+")")
return
}

path := "default.nix"
isNixFileExist := true
if _, err := os.Stat(path); os.IsNotExist(err) {
Expand Down
Loading