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))
|
const maxUInt32 = int(^uint32(0))
|
||||||
|
|
||||||
var infoVerbs cli.CommandMap
|
var getVerbs cli.CommandMap
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
infoVerbs = cli.CommandMap{
|
getVerbs = cli.CommandMap{
|
||||||
"list-mailboxes": LsMailboxCmd{},
|
"mailboxes": LsMailboxCmd{},
|
||||||
// "list-subscribed": LsSubscribedCmd{},
|
"messages": LsMsgCmd{},
|
||||||
"list-messages": LsMsgCmd{},
|
"content": CatMsgCmd{},
|
||||||
"display-message": 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 := flag.NewFlagSet(args[0], flag.ExitOnError)
|
||||||
flagset.Usage = func() { i.Help(os.Stdout, flagset) }
|
flagset.Usage = func() { i.Help(os.Stdout, flagset) }
|
||||||
flagset.Parse(args[1:])
|
flagset.Parse(args[1:])
|
||||||
|
@ -42,16 +42,16 @@ func (i InfoCmd) Func(args []string) error {
|
||||||
}
|
}
|
||||||
cmd := subArgs[0]
|
cmd := subArgs[0]
|
||||||
if Session.Info.Opts.Debug {
|
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) {
|
func (i GetCmd) Help(w io.Writer, set *flag.FlagSet) {
|
||||||
fmt.Fprintf(w, "USAGE: %s info VERB [verb opts]\n", Session.Info.Name)
|
fmt.Fprintf(w, "USAGE: %s get VERB [verb opts]\n", Session.Info.Name)
|
||||||
fmt.Fprintf(w, "\nVERBS:\n")
|
fmt.Fprintf(w, "\nVERBS:\n")
|
||||||
for verb := range infoVerbs {
|
for verb := range getVerbs {
|
||||||
fmt.Fprintf(w, "\t%s\n", verb)
|
fmt.Fprintf(w, "\t%s\n", verb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ type mailboxInfo struct {
|
||||||
|
|
||||||
func (l LsMailboxCmd) Func(args []string) error {
|
func (l LsMailboxCmd) Func(args []string) error {
|
||||||
if Session.Info.Opts.Debug {
|
if Session.Info.Opts.Debug {
|
||||||
Log.Debug("enter info list-mailboxes")
|
Log.Debug("enter get mailboxes")
|
||||||
}
|
}
|
||||||
var withAttributes bool
|
var withAttributes bool
|
||||||
var output string
|
var output string
|
||||||
|
@ -109,7 +109,7 @@ func (l LsMailboxCmd) Func(args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l LsMailboxCmd) Help(w io.Writer, set *flag.FlagSet) {
|
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")
|
fmt.Fprintf(w, "\nOPTS:\n")
|
||||||
set.PrintDefaults()
|
set.PrintDefaults()
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ type LsMsgCmd struct{}
|
||||||
|
|
||||||
func (l LsMsgCmd) Func(args []string) error {
|
func (l LsMsgCmd) Func(args []string) error {
|
||||||
if Session.Info.Opts.Debug {
|
if Session.Info.Opts.Debug {
|
||||||
Log.Debug("enter info list-messages")
|
Log.Debug("enter get messages")
|
||||||
}
|
}
|
||||||
var limit uint
|
var limit uint
|
||||||
var withSeq, withFrom, withDate, withFlags bool
|
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) {
|
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")
|
fmt.Fprintf(w, "\nOPTS:\n")
|
||||||
set.PrintDefaults()
|
set.PrintDefaults()
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ type CatMsgCmd struct{}
|
||||||
|
|
||||||
func (c CatMsgCmd) Func(args []string) error {
|
func (c CatMsgCmd) Func(args []string) error {
|
||||||
if Session.Info.Opts.Debug {
|
if Session.Info.Opts.Debug {
|
||||||
Log.Debug("enter info display-message")
|
Log.Debug("enter get content")
|
||||||
}
|
}
|
||||||
var idList []uint32
|
var idList []uint32
|
||||||
var withHeaders, withBody, withFlags, markRead bool
|
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) {
|
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")
|
fmt.Fprintf(w, "\nOPTS:\n")
|
||||||
set.PrintDefaults()
|
set.PrintDefaults()
|
||||||
}
|
}
|
|
@ -16,10 +16,10 @@ var Session struct {
|
||||||
var Log *log.Logger
|
var Log *log.Logger
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
info := InfoCmd{}
|
get := GetCmd{}
|
||||||
set := SetCmd{}
|
set := SetCmd{}
|
||||||
Session.Info.Commands = cli.CommandMap{
|
Session.Info.Commands = cli.CommandMap{
|
||||||
"info": info,
|
"get": get,
|
||||||
"set": set,
|
"set": set,
|
||||||
}
|
}
|
||||||
Session.Info.Name = "papero"
|
Session.Info.Name = "papero"
|
||||||
|
|
Loading…
Reference in a new issue