Skip to content

Commit eeb9993

Browse files
committed
init
0 parents  commit eeb9993

File tree

21 files changed

+1431
-0
lines changed

21 files changed

+1431
-0
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# My Project
2+
output
3+
logs

.editorconfig

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = false
9+
max_line_length = 120
10+
tab_width = 4
11+
12+
[{*.bash,*.sh,*.zsh}]
13+
indent_size = 2
14+
tab_width = 2
15+
16+
[{*.go,*.go2}]
17+
indent_style = tab
18+
19+
[{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config}]
20+
indent_size = 2
21+
22+
[{*.yaml,*.yml}]
23+
indent_size = 2
24+
25+
[*.md]
26+
trim_trailing_whitespace = false
27+
28+
[Makefile]
29+
indent_style = tab
30+
indent_size = 2

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool, specifically when used with LiteIDE
12+
*.out
13+
14+
# Dependency directories (remove the comment below to include it)
15+
# vendor/
16+
17+
# My Project
18+
output
19+
logs

.golangci.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
run:
2+
timeout: 1m
3+
4+
linters:
5+
disable-all: true
6+
enable:
7+
- deadcode
8+
- dupl
9+
- gofmt
10+
- goimports
11+
- gosimple
12+
- govet
13+
- ineffassign
14+
- misspell
15+
- nakedret
16+
- revive
17+
- staticcheck
18+
- structcheck
19+
- unused
20+
- varcheck
21+
22+
linters-settings:
23+
revive:
24+
# see https://github.com/mgechev/revive#available-rules for details.
25+
ignore-generated-header: true
26+
severity: warning
27+
rules:
28+
- name: indent-error-flow
29+
severity: warning
30+
- name: add-constant
31+
severity: warning
32+
arguments:
33+
- maxLitCount: "3"
34+
allowStrs: '""'
35+
allowInts: "0,1,2"
36+
allowFloats: "0.0,0.,1.0,1.,2.0,2."
37+
govet:
38+
# report about shadowed variables
39+
check-shadowing: true
40+
# settings per analyzer
41+
settings:
42+
printf: # analyzer name, run `go tool vet help` to see all analyzers
43+
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
44+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
45+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
46+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
47+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
48+
# enable or disable analyzers by name
49+
# run `go tool vet help` to see all analyzers
50+
enable-all: true

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 SaltFishPr
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

Makefile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# It's necessary to set this because some environments don't link sh -> bash.
2+
SHELL := /usr/bin/env bash
3+
4+
export WORKDIR=$(shell pwd)
5+
export APP_NAME=redis-viewer
6+
7+
.PHONY: build
8+
# build executable file for dev
9+
build:
10+
sh scripts/build.sh
11+
12+
.PHONY: run
13+
# run executable file
14+
run:
15+
sh output/run.sh
16+
17+
.PHONY: clean
18+
# clean build cache and docker images
19+
clean:
20+
sh scripts/clean.sh
21+
22+
.PHONY: generate
23+
# run go generate
24+
generate:
25+
go generate ./...
26+
27+
# show help
28+
help:
29+
@echo 'Usage:'
30+
@echo ' make [target]'
31+
@echo ''
32+
@echo 'Targets:'
33+
@awk '/^[a-zA-Z\-\w0-9]+:/ { \
34+
helpMessage = match(lastLine, /^# (.*)/); \
35+
if (helpMessage) { \
36+
helpCommand = substr($$1, 0, index($$1, ":")-1); \
37+
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
38+
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
39+
} \
40+
} \
41+
{ lastLine = $$0 }' $(MAKEFILE_LIST)
42+
43+
.DEFAULT_GOAL := help

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Redis Viewer

cmd/root.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package cmd
2+
3+
import (
4+
"log"
5+
"os"
6+
7+
"redis-viewer/internal/config"
8+
"redis-viewer/internal/tui"
9+
10+
tea "github.com/charmbracelet/bubbletea"
11+
"github.com/spf13/cobra"
12+
)
13+
14+
// rootCmd represents the base command when called without any subcommands
15+
var rootCmd = &cobra.Command{
16+
Use: "redis-viewer",
17+
Short: "A brief description of your application",
18+
Long: `A longer description that spans multiple lines and likely contains
19+
examples and usage of using your application. For example:
20+
21+
Cobra is a CLI library for Go that empowers applications.
22+
This application is a tool to generate the needed files
23+
to quickly create a Cobra application.`,
24+
Run: func(cmd *cobra.Command, args []string) {
25+
config.LoadConfig()
26+
27+
p := tea.NewProgram(tui.New(), tea.WithAltScreen(), tea.WithMouseAllMotion())
28+
if err := p.Start(); err != nil {
29+
log.Fatal("start failed: ", err)
30+
}
31+
},
32+
}
33+
34+
// Execute adds all child commands to the root command and sets flags appropriately.
35+
// This is called by main.main(). It only needs to happen once to the rootCmd.
36+
func Execute() {
37+
err := rootCmd.Execute()
38+
if err != nil {
39+
os.Exit(1)
40+
}
41+
}
42+
43+
func init() {
44+
// Here you will define your flags and configuration settings.
45+
// Cobra supports persistent flags, which, if defined here,
46+
// will be global for your application.
47+
48+
// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.redis-viewer.yaml)")
49+
50+
// Cobra also supports local flags, which will only run
51+
// when this action is called directly.
52+
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
53+
}

go.mod

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module redis-viewer
2+
3+
go 1.16
4+
5+
require (
6+
github.com/charmbracelet/bubbles v0.10.2
7+
github.com/charmbracelet/bubbletea v0.19.3
8+
github.com/charmbracelet/lipgloss v0.4.0
9+
github.com/spf13/cobra v1.3.0
10+
github.com/spf13/viper v1.10.1
11+
)

0 commit comments

Comments
 (0)