Skip to content

Commit

Permalink
feat: new app
Browse files Browse the repository at this point in the history
  • Loading branch information
oustn committed Mar 21, 2024
0 parents commit 3155cf2
Show file tree
Hide file tree
Showing 36 changed files with 4,119 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: build

on:
push:
tags:
- "master"

permissions:
contents: write

jobs:
build:
name: GoReleaser build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload assets
uses: actions/upload-artifact@v4
with:
name: qtg
path: dist/*
18 changes: 18 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: lint

on: [ push, pull_request ]
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: "latest"
only-new-issues: true
79 changes: 79 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

qtg
39 changes: 39 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
run:
timeout: 5m

linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- errcheck
- exportloopref
- gochecknoinits
- goconst
- gocritic
- gofmt
- goprintffuncname
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- noctx
- nolintlint
- rowserrcheck
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
- wastedassign
- nilerr
- godot
- godox
- goimports
41 changes: 41 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
project_name: "qtg"

before:
hooks:
- go mod tidy
- go mod download

builds:
- main: ./main.go
binary: qtg
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
- freebsd
- openbsd
- netbsd
goarch:
- amd64
- arm64
- "386"
- arm
goarm:
- "7"
ignore:
- goos: windows
goarch: arm64
- goos: windows
goarm: "7"

archives:
- format_overrides:
- goos: windows
format: zip

release:
github:
owner: oustn
name: qtg
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/QingtFMDownloader.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# QTG

1. 抓包拿到 token & id
2. 搜索 & 下载
55 changes: 55 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package cmd

import (
"fmt"
teaui "github.com/oustn/qtg/internal/ui"
"log"
"os"

tea "github.com/charmbracelet/bubbletea"
"github.com/oustn/qtg/internal/config"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "qtg",
Short: "一个有趣的蜻蜓 FM 下载器",
Version: "0.0.1",
Args: cobra.MaximumNArgs(0),
Run: func(cmd *cobra.Command, args []string) {
cfg, path, err := config.ParseConfig()
if err != nil {
log.Fatal(err)
}

if cfg.Settings.EnableLogging {
f, err := tea.LogToFile("debug.log", "debug")
if err != nil {
log.Fatal(err)
}

defer func() {
if err = f.Close(); err != nil {
log.Fatal(err)
}
}()
}

//m := ui.NewQ(&cfg, path)
m := teaui.NewRenderer(&cfg, path)
p := tea.NewProgram(m)
if _, err := p.Run(); err != nil {
log.Fatal("应用打开失败", err)
}
},
}

// Execute runs the root command and starts the application.
func Execute() {
rootCmd.AddCommand(updateCmd)

if err := rootCmd.Execute(); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
28 changes: 28 additions & 0 deletions cmd/update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package cmd

import (
"log"
"os"
"os/exec"

"github.com/spf13/cobra"
)

var updateCmd = &cobra.Command{
Use: "update",
Short: "更新 QTG 到最新版本",
Long: `更新 QTG 到最新版本.`,
Run: func(cmd *cobra.Command, args []string) {
updateCommand := exec.Command("bash", "-c", "curl -sfL https://raw.githubusercontent.com/oustn/qtg-go/master/install.sh | sh")
updateCommand.Stdin = os.Stdin
updateCommand.Stdout = os.Stdout
updateCommand.Stderr = os.Stderr

err := updateCommand.Run()
if err != nil {
log.Fatal(err)
}

os.Exit(0)
},
}
Loading

0 comments on commit 3155cf2

Please sign in to comment.