Skip to content

Commit

Permalink
v0.0.3 - 优化参数解析
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritLHLS committed Jul 2, 2024
1 parent 04a5f90 commit 1d7cb36
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
TAG="v0.0.2-$(date +'%Y%m%d%H%M%S')"
TAG="v0.0.3-$(date +'%Y%m%d%H%M%S')"
git tag $TAG
git push origin $TAG
env:
Expand Down
24 changes: 15 additions & 9 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"net/http"
"os"
"strings"

"github.com/oneclickvirt/CommonMediaTests/commediatests"
Expand All @@ -15,20 +16,25 @@ func main() {
http.Get("https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Foneclickvirt%2FCommonMediaTests&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false")
}()
fmt.Println(Green("项目地址:"), Yellow("https://github.com/oneclickvirt/CommonMediaTests"))
var showVersion bool
flag.BoolVar(&showVersion, "v", false, "show version")
languagePtr := flag.String("l", "", "Language parameter (en or zh)")
flag.BoolVar(&commediatests.EnableLoger, "e", false, "Enable logging")
flag.Parse()
var showVersion, help bool
var language string
cmtFlag := flag.NewFlagSet("cmt", flag.ContinueOnError)
cmtFlag.BoolVar(&help, "h", false, "Show help information")
cmtFlag.BoolVar(&showVersion, "v", false, "Show version")
cmtFlag.StringVar(&language, "l", "", "Language parameter (en or zh)")
cmtFlag.BoolVar(&commediatests.EnableLoger, "e", false, "Enable logging")
cmtFlag.Parse(os.Args[1:])
if help {
fmt.Printf("Usage: %s [options]\n", os.Args[0])
cmtFlag.PrintDefaults()
return
}
if showVersion {
fmt.Println(commediatests.ComMediaTestsVersion)
return
}
var language string
if *languagePtr == "" {
if language == "" {
language = "zh"
} else {
language = *languagePtr
}
language = strings.ToLower(language)
res := commediatests.MediaTests(language)
Expand Down
11 changes: 7 additions & 4 deletions commediatests/netflix/netflix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ package netflix

import (
"flag"
"os"

"github.com/oneclickvirt/CommonMediaTests/commediatests/netflix/printer"
"github.com/oneclickvirt/CommonMediaTests/commediatests/netflix/verify"
)

var custom = flag.String("custom", "", "自定义测试NF影片ID\n绝命毒师的ID是70143836")
var address = flag.String("address", "", "本机网卡的IP")
var proxy = flag.String("proxy", "", "代理地址")
var cmtnFlag = flag.NewFlagSet("cmtn", flag.ContinueOnError)
var custom = cmtnFlag.String("custom", "", "自定义测试NF影片ID\n绝命毒师的ID是70143836")
var address = cmtnFlag.String("address", "", "本机网卡的IP")
var proxy = cmtnFlag.String("proxy", "", "代理地址")

func Netflix(language string) (string, error) {
flag.Parse()
cmtnFlag.Parse(os.Args[1:])
r := verify.NewVerify(verify.Config{
LocalAddr: *address,
Custom: *custom,
Expand Down
2 changes: 1 addition & 1 deletion commediatests/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package commediatests

const ComMediaTestsVersion = "v0.0.2"
const ComMediaTestsVersion = "v0.0.3"
var EnableLoger bool

0 comments on commit 1d7cb36

Please sign in to comment.