From ed2a63a68c4727c1f4a37c41928e436448b78ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=BA=C5=A1=20Ollah?= Date: Fri, 29 Mar 2024 19:22:18 +0100 Subject: [PATCH] Initial commit --- .gitattributes | 2 ++ .gitignore | 21 +++++++++++++++++++++ LICENSE | 21 +++++++++++++++++++++ go.mod | 3 +++ main.go | 41 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 go.mod create mode 100644 main.go diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3b735ec --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# 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 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2c1a22d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Matúš Ollah + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..3860e0a --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/MatusOllah/go-yes + +go 1.22.0 diff --git a/main.go b/main.go new file mode 100644 index 0000000..f0f7bb8 --- /dev/null +++ b/main.go @@ -0,0 +1,41 @@ +package main + +import ( + "flag" + "fmt" + "os" + "runtime" + "strings" +) + +const ver string = "1.0.0" + +func main() { + help := flag.Bool("help", false, "display this help and exit") + version := flag.Bool("version", false, "output version information and exit") + flag.Parse() + + if *help { + fmt.Fprintln(os.Stderr, "go-yes repeatedly outputs a line with specified string, or 'y'.") + fmt.Fprintln(os.Stderr) + fmt.Fprintf(os.Stderr, "Usage: %s [OPTIONS]\n", os.Args[0]) + fmt.Fprintln(os.Stderr) + fmt.Fprintln(os.Stderr, "Options:") + flag.PrintDefaults() + os.Exit(0) + } + + if *version { + fmt.Fprintf(os.Stderr, "go-yes version %s\n", ver) + fmt.Fprintf(os.Stderr, "Go version %s\n", runtime.Version()) + os.Exit(0) + } + + for { + if len(os.Args) >= 2 { + fmt.Fprintln(os.Stdout, strings.Join(os.Args[1:], " ")) + } else { + fmt.Fprintln(os.Stdout, "y") + } + } +}