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:
14 // BUG(op) it cannot change the text before the | character.
27 cl = flag.Bool("c", false, `Clear the tag`)
28 gt = flag.Bool("g", false, `Get the content of the tag`)
31 func open() (*acme.Win, error) {
32 winid := os.Getenv("winid")
33 id, err := strconv.Atoi(winid)
37 win, err := acme.Open(id, nil)
43 fmt.Println(me, "- manage acme(1) tag")
44 fmt.Println("Usage:", me, " [-cg] [entries...]")
45 fmt.Println(" where entries are words to be added to the acme tag bar")
58 defer win.CloseFiles()
61 tag, err := win.ReadAll("tag")
65 fmt.Println(string(tag))
73 for _, arg := range flag.Args() {
74 _, err = win.Write("tag", []byte(sep+arg))