This commit is contained in:
lilo
2022-02-15 18:45:01 -08:00
parent 1347a7d534
commit d1b803f598
6 changed files with 325 additions and 0 deletions

147
.gitignore vendored Normal file
View File

@@ -0,0 +1,147 @@
# Created by https://www.toptal.com/developers/gitignore/api/go,vim,windows,macos,linux,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=go,vim,windows,macos,linux,visualstudiocode
### Go ###
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace file
go.work
### Go Patch ###
/vendor/
/Godeps/
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Vim ###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
Sessionx.vim
# Temporary
.netrwhist
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
# Support for Project snippet scope
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.toptal.com/developers/gitignore/api/go,vim,windows,macos,linux,visualstudiocode
# Add by lilo
target/

22
Makefile Normal file
View File

@@ -0,0 +1,22 @@
.PHONY: all
all:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o target/altgvn-linux-amd64 main.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ go build -o target/altgvn-linux-arm64 main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o target/altgvn-darwin-amd64 main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o target/altgvn-darwin-arm64 main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o target/altgvn-windows-amd64.exe main.go
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -o target/altgvn-freebsd-amd64 main.go
macOS:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o target/altgvn-darwin-amd64 main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o target/altgvn-darwin-arm64 main.go
linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o target/altgvn-linux-amd64 main.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ go build -o target/altgvn-linux-arm64 main.go
windows:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o target/altgvn-windows-amd64.exe main.go
freebsd:
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -o target/altgvn-freebsd-amd64 main.go
clean:
rm -rf target
format:
go fmt ./...

View File

@@ -7,6 +7,9 @@ git init . && git add . && git commit -m "Init"
# Add cobra.yaml
cobra init --config cobra.yaml
git add . && git commit -m "cobra init"
cobra add init --config cobra.yaml
cobra add up --config cobra.yaml
cobra add down --config cobra.yaml
```
---

51
cmd/down.go Normal file
View File

@@ -0,0 +1,51 @@
/*
Copyright © 2022 liluo <luolee.me@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
// downCmd represents the down command
var downCmd = &cobra.Command{
Use: "down",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("down called")
},
}
func init() {
rootCmd.AddCommand(downCmd)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// downCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// downCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

51
cmd/init.go Normal file
View File

@@ -0,0 +1,51 @@
/*
Copyright © 2022 liluo <luolee.me@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
// initCmd represents the init command
var initCmd = &cobra.Command{
Use: "init",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("init called")
},
}
func init() {
rootCmd.AddCommand(initCmd)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// initCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// initCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

51
cmd/up.go Normal file
View File

@@ -0,0 +1,51 @@
/*
Copyright © 2022 liluo <luolee.me@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
// upCmd represents the up command
var upCmd = &cobra.Command{
Use: "up",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("up called")
},
}
func init() {
rootCmd.AddCommand(upCmd)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// upCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// upCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}