|
package main
import (
"os"
"path/filepath"
"github.com/codegangsta/cli"
)
// Command line subcommand for "clear"
var commandClear = cli.Command{
Name: "clear",
ShortName: "",
Usage: "",
Action: actionClear,
Flags: []cli.Flag{
cli.StringFlag{
Name: "file",
Value: "general.ledger",
Usage: "",
},
},
}
// Clear current pending transaction
func actionClear(c *cli.Context) {
pendingFile := filepath.Join(os.TempDir(), c.String("file"))
ensureFileExists(pendingFile)
file, err := os.OpenFile(pendingFile, os.O_TRUNC|os.O_WRONLY, 0666)
check(err)
defer file.Close()
_, err = file.Write([]byte{})
check(err)
}
|