From ec8c16bcc8f8d629d7b2fd6c34062fe2afd721b1 Mon Sep 17 00:00:00 2001 From: Mussabaheen Malik Date: Mon, 25 Mar 2024 16:38:20 +0100 Subject: [PATCH] feat: add readme for clipboard --- LICENSE | 21 +++++++++++++++++++++ README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ main.go | 10 +++++++++- 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7adc1ef --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) [2024] [Mussabeheen] + +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/README.md b/README.md new file mode 100644 index 0000000..9349904 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ + +# MacOS ClipBoard + +App to maintain the clipboard history for MacOS + +## Run Locally + +Clone the project + +```bash + git clone https://github.com/Mussabaheen/clipboard +``` + +Go to the project directory + +```bash + cd clipboard +``` + +Install dependencies + +```bash + go mod tidy +``` + +Start the clipboard server + +```bash + go run main.go +``` + +## Configurable arguments +### PORT +port on which you want to serve your clipboard UI +``` + --port +``` + +## Authors + +- [@mussabeheen-malik](https://www.linkedin.com/in/mussabaheen-malik/) + + +## Contributing + +Contributions are always welcome! + +There is always room for improvements feel free to create issues or pull requests. + +If you have any questions feel free to email at mussabaheen@gmail.com + diff --git a/main.go b/main.go index 03f5951..0e76efc 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "context" "encoding/json" + "flag" "fmt" "net/http" "path" @@ -14,7 +15,14 @@ import ( var data []string var clients = make(map[chan []byte]struct{}) +var ( + localPortUsage = "Specify the port number on which you want to serve the UI, by default 8080" +) + func main() { + // localPort represents the arg with flag -p + localPort := flag.String("port", "8080", localPortUsage) + flag.Parse() err := clipboard.Init() if err != nil { panic(err) @@ -25,7 +33,7 @@ func main() { http.HandleFunc("/", ShowClipboard) http.HandleFunc("/updates", UpdatesHandler) - err = http.ListenAndServe(":8080", nil) + err = http.ListenAndServe(":"+*localPort, nil) if err != nil { panic("error occured while running clipboard : " + err.Error()) }