From 38ee83e45b4de7edf89bf9f0ef629eb4c6ad0fa8 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Thu, 12 May 2016 23:56:07 -0400 Subject: Moving to glide --- .../github.com/mattermost/rsc/cmd/crypt/crypt.go | 79 +++++++++ .../github.com/mattermost/rsc/cmd/issue/issue.go | 185 +++++++++++++++++++++ vendor/github.com/mattermost/rsc/cmd/jfmt/main.go | 37 +++++ 3 files changed, 301 insertions(+) create mode 100644 vendor/github.com/mattermost/rsc/cmd/crypt/crypt.go create mode 100644 vendor/github.com/mattermost/rsc/cmd/issue/issue.go create mode 100644 vendor/github.com/mattermost/rsc/cmd/jfmt/main.go (limited to 'vendor/github.com/mattermost/rsc/cmd') diff --git a/vendor/github.com/mattermost/rsc/cmd/crypt/crypt.go b/vendor/github.com/mattermost/rsc/cmd/crypt/crypt.go new file mode 100644 index 000000000..4a2150540 --- /dev/null +++ b/vendor/github.com/mattermost/rsc/cmd/crypt/crypt.go @@ -0,0 +1,79 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Crypt is a simple password-based encryption program, +// demonstrating how to use github.com/mattermost/rsc/crypt. +// +// Encrypt input to output using password: +// crypt password output +// +// Decrypt input to output using password: +// crypt -d password output +// +// Yes, the password is a command-line argument. This is a demo of the +// github.com/mattermost/rsc/crypt package. It's not intended for real use. +// +package main + +import ( + "encoding/base64" + "fmt" + "io/ioutil" + "os" + "strings" + + "github.com/mattermost/rsc/crypt" +) + +func main() { + args := os.Args[1:] + encrypt := true + if len(args) >= 1 && args[0] == "-d" { + encrypt = false + args = args[1:] + } + if len(args) != 1 || strings.HasPrefix(args[0], "-") { + fmt.Fprintf(os.Stderr, "usage: crypt [-d] password < input > output\n") + os.Exit(2) + } + password := args[0] + + data, err := ioutil.ReadAll(os.Stdin) + if err != nil { + fmt.Fprintf(os.Stderr, "reading stdin: %v\n", err) + os.Exit(1) + } + if encrypt { + pkt, err := crypt.Encrypt(password, data) + if err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + os.Exit(1) + } + str := base64.StdEncoding.EncodeToString(pkt) + for len(str) > 60 { + fmt.Printf("%s\n", str[:60]) + str = str[60:] + } + fmt.Printf("%s\n", str) + } else { + pkt, err := base64.StdEncoding.DecodeString(strings.Map(noSpace, string(data))) + if err != nil { + fmt.Fprintf(os.Stderr, "decoding input: %v\n", err) + os.Exit(1) + } + dec, err := crypt.Decrypt(password, pkt) + if err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + os.Exit(1) + } + os.Stdout.Write(dec) + } +} + +func noSpace(r rune) rune { + if r == ' ' || r == '\t' || r == '\n' { + return -1 + } + return r +} diff --git a/vendor/github.com/mattermost/rsc/cmd/issue/issue.go b/vendor/github.com/mattermost/rsc/cmd/issue/issue.go new file mode 100644 index 000000000..651a65d96 --- /dev/null +++ b/vendor/github.com/mattermost/rsc/cmd/issue/issue.go @@ -0,0 +1,185 @@ +package main + +import ( + "encoding/xml" + "flag" + "fmt" + "html" + "log" + "net/http" + "net/url" + "os" + "sort" + "strconv" + "strings" + "time" +) + +func usage() { + fmt.Fprintf(os.Stderr, `usage: issue [-p project] query + +If query is a single number, prints the full history for the issue. +Otherwise, prints a table of matching results. +The special query 'go1' is shorthand for 'Priority-Go1'. +`) + os.Exit(2) +} + +type Feed struct { + Entry Entries `xml:"entry"` +} + +type Entry struct { + ID string `xml:"id"` + Title string `xml:"title"` + Published time.Time `xml:"published"` + Content string `xml:"content"` + Updates []Update `xml:"updates"` + Author struct { + Name string `xml:"name"` + } `xml:"author"` + Owner string `xml:"owner"` + Status string `xml:"status"` + Label []string `xml:"label"` +} + +type Update struct { + Summary string `xml:"summary"` + Owner string `xml:"ownerUpdate"` + Label string `xml:"label"` + Status string `xml:"status"` +} + +type Entries []Entry + +func (e Entries) Len() int { return len(e) } +func (e Entries) Swap(i, j int) { e[i], e[j] = e[j], e[i] } +func (e Entries) Less(i, j int) bool { return e[i].Title < e[j].Title } + +var project = flag.String("p", "go", "code.google.com project identifier") +var v = flag.Bool("v", false, "verbose") + +func main() { + flag.Usage = usage + flag.Parse() + if flag.NArg() != 1 { + usage() + } + + full := false + q := flag.Arg(0) + n, _ := strconv.Atoi(q) + if n != 0 { + q = "id:" + q + full = true + } + if q == "go1" { + q = "label:Priority-Go1" + } + + log.SetFlags(0) + + query := url.Values{ + "q": {q}, + "max-results": {"400"}, + } + if !full { + query["can"] = []string{"open"} + } + u := "https://code.google.com/feeds/issues/p/" + *project + "/issues/full?" + query.Encode() + if *v { + log.Print(u) + } + r, err := http.Get(u) + if err != nil { + log.Fatal(err) + } + + var feed Feed + if err := xml.NewDecoder(r.Body).Decode(&feed); err != nil { + log.Fatal(err) + } + r.Body.Close() + + sort.Sort(feed.Entry) + for _, e := range feed.Entry { + id := e.ID + if i := strings.Index(id, "id="); i >= 0 { + id = id[:i+len("id=")] + } + fmt.Printf("%s\t%s\n", id, e.Title) + if full { + fmt.Printf("Reported by %s (%s)\n", e.Author.Name, e.Published.Format("2006-01-02 15:04:05")) + if e.Owner != "" { + fmt.Printf("\tOwner: %s\n", e.Owner) + } + if e.Status != "" { + fmt.Printf("\tStatus: %s\n", e.Status) + } + for _, l := range e.Label { + fmt.Printf("\tLabel: %s\n", l) + } + if e.Content != "" { + fmt.Printf("\n\t%s\n", wrap(html.UnescapeString(e.Content), "\t")) + } + u := "https://code.google.com/feeds/issues/p/" + *project + "/issues/" + id + "/comments/full" + if *v { + log.Print(u) + } + r, err := http.Get(u) + if err != nil { + log.Fatal(err) + } + + var feed Feed + if err := xml.NewDecoder(r.Body).Decode(&feed); err != nil { + log.Fatal(err) + } + r.Body.Close() + + for _, e := range feed.Entry { + fmt.Printf("\n%s (%s)\n", e.Title, e.Published.Format("2006-01-02 15:04:05")) + for _, up := range e.Updates { + if up.Summary != "" { + fmt.Printf("\tSummary: %s\n", up.Summary) + } + if up.Owner != "" { + fmt.Printf("\tOwner: %s\n", up.Owner) + } + if up.Status != "" { + fmt.Printf("\tStatus: %s\n", up.Status) + } + if up.Label != "" { + fmt.Printf("\tLabel: %s\n", up.Label) + } + } + if e.Content != "" { + fmt.Printf("\n\t%s\n", wrap(html.UnescapeString(e.Content), "\t")) + } + } + } + } +} + +func wrap(t string, prefix string) string { + out := "" + t = strings.Replace(t, "\r\n", "\n", -1) + lines := strings.Split(t, "\n") + for i, line := range lines { + if i > 0 { + out += "\n" + prefix + } + s := line + for len(s) > 70 { + i := strings.LastIndex(s[:70], " ") + if i < 0 { + i = 69 + } + i++ + out += s[:i] + "\n" + prefix + s = s[i:] + } + out += s + } + return out +} diff --git a/vendor/github.com/mattermost/rsc/cmd/jfmt/main.go b/vendor/github.com/mattermost/rsc/cmd/jfmt/main.go new file mode 100644 index 000000000..31c5eddfc --- /dev/null +++ b/vendor/github.com/mattermost/rsc/cmd/jfmt/main.go @@ -0,0 +1,37 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// jfmt reads JSON from standard input, formats it, and writes it to standard output. +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + "log" + "os" +) + +func main() { + log.SetFlags(0) + + if len(os.Args) > 1 { + fmt.Fprintf(os.Stderr, "usage: json < input > output\n") + os.Exit(2) + } + + // TODO: Can do on the fly. + + data, err := ioutil.ReadAll(os.Stdin) + if err != nil { + log.Fatal(err) + } + + var buf bytes.Buffer + json.Indent(&buf, data, "", " ") + buf.WriteByte('\n') + + os.Stdout.Write(buf.Bytes()) +} -- cgit v1.2.3-1-g7c22