Skip to content

Commit

Permalink
add golines + staticcheck + go-update
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDen committed Dec 2, 2023
1 parent fc4baef commit ad8efc3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,30 @@ build_and_run: build run
mod:
go mod tidy
go mod vendor
go mod verify

go-update:
go list -mod=readonly -m -f '{{if not .Indirect}}{{if not .Main}}{{.Path}}{{end}}{{end}}' all | xargs go get -u
$(MAKE) mod

gosec:
gosec -severity medium ./...

golines-format:
# https://github.com/segmentio/golines
@printf "%s\n" "==== Run golines ====="
golines --write-output --ignored-dirs=vendor .

go-staticcheck:
# https://github.com/dominikh/go-tools
staticcheck ./...

format:
gofmt -s -w *.go
prettier -w .

clean:
go clean
rm -rf ./bin/*


14 changes: 12 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ func getFileClass(fileContent []byte) (string, string) {

func createCommand(absfileName string, fileClass string, rawData bool) (command string) {
if len(fileClass) > 0 {
command = fmt.Sprintf("set the clipboard to (read (POSIX file \"%s\") as %s)", absfileName, fileClass)
command = fmt.Sprintf(
"set the clipboard to (read (POSIX file \"%s\") as %s)",
absfileName,
fileClass,
)
} else if rawData {
command = fmt.Sprintf("set the clipboard to (read (POSIX file \"%s\"))", absfileName)
} else {
Expand Down Expand Up @@ -130,7 +134,13 @@ func readFromStdinUntilSigEOF() {
func main() {
parser := argparse.NewParser("gcopy [file] [STDIN]", "gcopy: copy content to the clipboard")
printVersion := parser.Flag("v", "version", &argparse.Options{Help: "Current version"})
pathName := parser.Flag("p", "path", &argparse.Options{Help: "Copy (and show) the absolute path of a file or folder to the clipboard"})
pathName := parser.Flag(
"p",
"path",
&argparse.Options{
Help: "Copy (and show) the absolute path of a file or folder to the clipboard",
},
)
var fileName *string = parser.StringPositional(&argparse.Options{Help: "DISABLEDDESCRIPTIONWILLNOTSHOWUP"})
parser.Parse(os.Args)

Expand Down

0 comments on commit ad8efc3

Please sign in to comment.