Rename info verb into get
This commit is contained in:
parent
a3430dfdf2
commit
aefa3c6c59
2 changed files with 22 additions and 22 deletions
|
@ -18,20 +18,20 @@ import (
|
|||
|
||||
const maxUInt32 = int(^uint32(0))
|
||||
|
||||
var infoVerbs cli.CommandMap
|
||||
var getVerbs cli.CommandMap
|
||||
|
||||
func init() {
|
||||
infoVerbs = cli.CommandMap{
|
||||
"list-mailboxes": LsMailboxCmd{},
|
||||
// "list-subscribed": LsSubscribedCmd{},
|
||||
"list-messages": LsMsgCmd{},
|
||||
"display-message": CatMsgCmd{},
|
||||
getVerbs = cli.CommandMap{
|
||||
"mailboxes": LsMailboxCmd{},
|
||||
"messages": LsMsgCmd{},
|
||||
"content": CatMsgCmd{},
|
||||
// "subscriptions": LsSubscribedCmd{},
|
||||
}
|
||||
}
|
||||
|
||||
type InfoCmd struct{}
|
||||
type GetCmd struct{}
|
||||
|
||||
func (i InfoCmd) Func(args []string) error {
|
||||
func (i GetCmd) Func(args []string) error {
|
||||
flagset := flag.NewFlagSet(args[0], flag.ExitOnError)
|
||||
flagset.Usage = func() { i.Help(os.Stdout, flagset) }
|
||||
flagset.Parse(args[1:])
|
||||
|
@ -42,16 +42,16 @@ func (i InfoCmd) Func(args []string) error {
|
|||
}
|
||||
cmd := subArgs[0]
|
||||
if Session.Info.Opts.Debug {
|
||||
Log.Debug("info verb:", cmd)
|
||||
Log.Debug("get verbs:", cmd)
|
||||
}
|
||||
|
||||
return infoVerbs[cmd].Func(subArgs)
|
||||
return getVerbs[cmd].Func(subArgs)
|
||||
}
|
||||
|
||||
func (i InfoCmd) Help(w io.Writer, set *flag.FlagSet) {
|
||||
fmt.Fprintf(w, "USAGE: %s info VERB [verb opts]\n", Session.Info.Name)
|
||||
func (i GetCmd) Help(w io.Writer, set *flag.FlagSet) {
|
||||
fmt.Fprintf(w, "USAGE: %s get VERB [verb opts]\n", Session.Info.Name)
|
||||
fmt.Fprintf(w, "\nVERBS:\n")
|
||||
for verb := range infoVerbs {
|
||||
for verb := range getVerbs {
|
||||
fmt.Fprintf(w, "\t%s\n", verb)
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ type mailboxInfo struct {
|
|||
|
||||
func (l LsMailboxCmd) Func(args []string) error {
|
||||
if Session.Info.Opts.Debug {
|
||||
Log.Debug("enter info list-mailboxes")
|
||||
Log.Debug("enter get mailboxes")
|
||||
}
|
||||
var withAttributes bool
|
||||
var output string
|
||||
|
@ -109,7 +109,7 @@ func (l LsMailboxCmd) Func(args []string) error {
|
|||
}
|
||||
|
||||
func (l LsMailboxCmd) Help(w io.Writer, set *flag.FlagSet) {
|
||||
fmt.Fprintf(w, "USAGE: %s info list-mailboxes [opts]\n", Session.Info.Name)
|
||||
fmt.Fprintf(w, "USAGE: %s get mailboxes [opts]\n", Session.Info.Name)
|
||||
fmt.Fprintf(w, "\nOPTS:\n")
|
||||
set.PrintDefaults()
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ type LsMsgCmd struct{}
|
|||
|
||||
func (l LsMsgCmd) Func(args []string) error {
|
||||
if Session.Info.Opts.Debug {
|
||||
Log.Debug("enter info list-messages")
|
||||
Log.Debug("enter get messages")
|
||||
}
|
||||
var limit uint
|
||||
var withSeq, withFrom, withDate, withFlags bool
|
||||
|
@ -155,7 +155,7 @@ func (l LsMsgCmd) Func(args []string) error {
|
|||
}
|
||||
|
||||
func (l LsMsgCmd) Help(w io.Writer, set *flag.FlagSet) {
|
||||
fmt.Fprintf(w, "USAGE: %s info list-messages [opts] MAILBOX_NAME\n", Session.Info.Name)
|
||||
fmt.Fprintf(w, "USAGE: %s get messages [opts] MAILBOX_NAME\n", Session.Info.Name)
|
||||
fmt.Fprintf(w, "\nOPTS:\n")
|
||||
set.PrintDefaults()
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ type CatMsgCmd struct{}
|
|||
|
||||
func (c CatMsgCmd) Func(args []string) error {
|
||||
if Session.Info.Opts.Debug {
|
||||
Log.Debug("enter info display-message")
|
||||
Log.Debug("enter get content")
|
||||
}
|
||||
var idList []uint32
|
||||
var withHeaders, withBody, withFlags, markRead bool
|
||||
|
@ -294,7 +294,7 @@ func (c CatMsgCmd) Func(args []string) error {
|
|||
}
|
||||
|
||||
func (c CatMsgCmd) Help(w io.Writer, set *flag.FlagSet) {
|
||||
fmt.Fprintf(w, "USAGE: %s info display-message [opts] MAILBOX_NAME [MESSAGE_ID1 [MESSAGE_ID2 [...]]]\n", Session.Info.Name)
|
||||
fmt.Fprintf(w, "USAGE: %s get content [opts] MAILBOX_NAME [MESSAGE_ID1 [MESSAGE_ID2 [...]]]\n", Session.Info.Name)
|
||||
fmt.Fprintf(w, "\nOPTS:\n")
|
||||
set.PrintDefaults()
|
||||
}
|
|
@ -16,11 +16,11 @@ var Session struct {
|
|||
var Log *log.Logger
|
||||
|
||||
func init() {
|
||||
info := InfoCmd{}
|
||||
get := GetCmd{}
|
||||
set := SetCmd{}
|
||||
Session.Info.Commands = cli.CommandMap{
|
||||
"info": info,
|
||||
"set": set,
|
||||
"get": get,
|
||||
"set": set,
|
||||
}
|
||||
Session.Info.Name = "papero"
|
||||
flag.Usage = func() { cli.Usage(os.Stdout, Session.Info) }
|
||||
|
|
Loading…
Reference in a new issue