10 14b3f96d 2019-10-26 op "9fans.net/go/acme"
14 14b3f96d 2019-10-26 op cl = flag.Bool("c", false, `Clear the tag`)
15 6c2d529b 2019-10-26 op gt = flag.Bool("g", false, `Get the content of the tag`)
18 14b3f96d 2019-10-26 op func open() (*acme.Win, error) {
19 14b3f96d 2019-10-26 op winid := os.Getenv("winid")
20 14b3f96d 2019-10-26 op id, err := strconv.Atoi(winid)
21 14b3f96d 2019-10-26 op if err != nil {
22 14b3f96d 2019-10-26 op return nil, err
24 14b3f96d 2019-10-26 op win, err := acme.Open(id, nil)
25 14b3f96d 2019-10-26 op return win, err
28 14b3f96d 2019-10-26 op func usage() {
29 14b3f96d 2019-10-26 op me := os.Args[0]
30 14b3f96d 2019-10-26 op fmt.Println(me, "- manage acme(1) tag")
31 14b3f96d 2019-10-26 op fmt.Println("Usage:", me, " [-ch] entries...")
32 14b3f96d 2019-10-26 op fmt.Println(" where entries are words to be added to acme' tag bar")
33 14b3f96d 2019-10-26 op flag.PrintDefaults()
38 14b3f96d 2019-10-26 op flag.Usage = usage
41 14b3f96d 2019-10-26 op win, err := open()
42 14b3f96d 2019-10-26 op if err != nil {
45 14b3f96d 2019-10-26 op defer win.CloseFiles()
48 6c2d529b 2019-10-26 op tag, err := win.ReadAll("tag")
49 6c2d529b 2019-10-26 op if err != nil {
50 6c2d529b 2019-10-26 op log.Fatalln(err)
52 6c2d529b 2019-10-26 op fmt.Println(string(tag))
56 14b3f96d 2019-10-26 op win.Ctl("cleartag")
60 14b3f96d 2019-10-26 op for _, arg := range flag.Args() {
61 14b3f96d 2019-10-26 op _, err = win.Write("tag", []byte(sep+arg))