From d1b803f598ad8a5e76bb025cd80e6a75053eadc3 Mon Sep 17 00:00:00 2001 From: lilo Date: Tue, 15 Feb 2022 18:45:01 -0800 Subject: [PATCH] update --- .gitignore | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 22 ++++++++ README.md | 3 ++ cmd/down.go | 51 ++++++++++++++++++ cmd/init.go | 51 ++++++++++++++++++ cmd/up.go | 51 ++++++++++++++++++ 6 files changed, 325 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 cmd/down.go create mode 100644 cmd/init.go create mode 100644 cmd/up.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5dfcc0f --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..837fefb --- /dev/null +++ b/Makefile @@ -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 ./... diff --git a/README.md b/README.md index f4e03fb..51abc95 100644 --- a/README.md +++ b/README.md @@ -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 ``` --- diff --git a/cmd/down.go b/cmd/down.go new file mode 100644 index 0000000..dfdbff4 --- /dev/null +++ b/cmd/down.go @@ -0,0 +1,51 @@ +/* +Copyright © 2022 liluo + +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") +} diff --git a/cmd/init.go b/cmd/init.go new file mode 100644 index 0000000..7cbd327 --- /dev/null +++ b/cmd/init.go @@ -0,0 +1,51 @@ +/* +Copyright © 2022 liluo + +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") +} diff --git a/cmd/up.go b/cmd/up.go new file mode 100644 index 0000000..a2556e2 --- /dev/null +++ b/cmd/up.go @@ -0,0 +1,51 @@ +/* +Copyright © 2022 liluo + +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") +}