Skip to content

Commit

Permalink
add version
Browse files Browse the repository at this point in the history
  • Loading branch information
DesSolo committed Sep 4, 2020
1 parent 8d7b9d3 commit c7af5c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
PROJECTNAME="m3ujson"
BUILD_DIRECTORY="bin"
VERSION=${shell grep "const AppVersion" main.go | cut -d '"' -f 2}

clean:
@echo " > Clean directory..."
@rm -rf bin

build: clean
@echo " > Building binary..."
@go build -o ${BUILD_DIRECTORY}/${PROJECTNAME}
@go build -o ${BUILD_DIRECTORY}/${PROJECTNAME}-${VERSION}

run:
@echo " > Run..."
Expand All @@ -16,6 +17,6 @@ run:
compile: clean
@echo " > Build binary all arch..."
@echo "+linux amd64"
@GOOS=linux GOARCH=amd64 go build -o ${BUILD_DIRECTORY}/${PROJECTNAME}-linux-amd64
@GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o ${BUILD_DIRECTORY}/${PROJECTNAME}-${VERSION}-linux-amd64
@echo "+mipsle"
@GOOS=linux GOARCH=mipsle go build -o ${BUILD_DIRECTORY}/${PROJECTNAME}-mipsle
@GOOS=linux GOARCH=mipsle go build -ldflags "-s -w" -o ${BUILD_DIRECTORY}/${PROJECTNAME}-${VERSION}-mipsle
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"os"
"encoding/json"
"errors"
"flag"
Expand All @@ -12,6 +13,9 @@ import (
"strings"
)

// AppVersion application version
const AppVersion = "1.0.0"

// provider is variable of provider name like Edem, etc
var provider string

Expand Down Expand Up @@ -65,9 +69,15 @@ func convertToStruct(m3u []byte) ([]TVChannel, error) {
}

func main() {
version := flag.Bool("version", false, "Show version and exit")
flag.StringVar(&provider, "p", "Edem", "Provider name")
flag.Parse()

if *version {
fmt.Println(AppVersion)
os.Exit(0)
}

if len(flag.Args()) < 1 {
flag.Usage()
log.Fatalln("url should be specifically")
Expand Down

0 comments on commit c7af5c7

Please sign in to comment.