From 6d83f4cdd9283ea8507e86fd7d6984ba1c21b0f2 Mon Sep 17 00:00:00 2001 From: Diff Date: Thu, 12 Nov 2020 22:06:19 +0000 Subject: [PATCH] Basic functionality --- .gitignore | 1 + README.md | 7 +++++++ main.go | 26 +++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7863201 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Venture \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e9d2a43 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Venture + +A way to let other people know what the heck you're up to. + +## Usage: + +`venture "[message]"` \ No newline at end of file diff --git a/main.go b/main.go index f9c9dae..e72b703 100644 --- a/main.go +++ b/main.go @@ -2,8 +2,32 @@ package main import ( "fmt" + "path" + "os" + "os/user" + "io" + "io/ioutil" + "bufio" ) func main() { - fmt.Println("Hello, world!") + curUser, err := user.Current() + if err != nil { + panic(err) + } + + fmt.Printf("What's ~%v been up to?\n~%v", curUser.Username, curUser.Username) + reader := bufio.NewReader(os.Stdin) + input, err := reader.ReadString('\n') + if err != nil && err != io.EOF { + panic(err) + } + + input = "~"+curUser.Username+input + + outputPath := path.Join(curUser.HomeDir, ".venture") + err = ioutil.WriteFile(outputPath, []byte(input), 0644) + if err != nil { + panic(err) + } } \ No newline at end of file