1 // acmetag is a tool to programmatically interact with acme(1) tag
2 // bar. It provides two flag:
4 // * -g prints the tag content (mnemonic: get)
5 // * -c clears the tag content (mnemonic: clear)
7 // Any other argument (if passed) will be appended to the tag bar.
9 // Of course, you can combine the flags:
13 // BUG(op) it cannot change the text before the | character.
14 // AFAIK that's not possible
28 cl = flag.Bool("c", false, `Clear the tag`)
29 gt = flag.Bool("g", false, `Get the content of the tag`)
32 func open() (*acme.Win, error) {
33 winid := os.Getenv("winid")
34 id, err := strconv.Atoi(winid)
38 win, err := acme.Open(id, nil)
44 fmt.Println(me, "- manage acme(1) tag")
45 fmt.Println("Usage:", me, " [-cg] [entries...]")
46 fmt.Println(" where entries are words to be added to the acme tag bar")
59 defer win.CloseFiles()
62 tag, err := win.ReadAll("tag")
66 fmt.Println(string(tag))
74 for _, arg := range flag.Args() {
75 _, err = win.Write("tag", []byte(sep+arg))