jp (base): add flag for use_pubsub to add cache skipping option
This commit is contained in:
parent
aab8a38836
commit
d10ce3ad7a
4 changed files with 22 additions and 5 deletions
|
|
@ -34,6 +34,7 @@ import tty
|
|||
import termios
|
||||
from pathlib import Path
|
||||
from glob import iglob
|
||||
from typing import Optional
|
||||
from importlib import import_module
|
||||
from sat_frontends.tools.jid import JID
|
||||
from sat.tools import config
|
||||
|
|
@ -332,7 +333,7 @@ class LiberviaCli:
|
|||
|
||||
|
||||
def make_pubsub_group(self, flags, defaults):
|
||||
"""generate pubsub options according to flags
|
||||
"""Generate pubsub options according to flags
|
||||
|
||||
@param flags(iterable[unicode]): see [CommandBase.__init__]
|
||||
@param defaults(dict[unicode, unicode]): help text for default value
|
||||
|
|
@ -402,7 +403,7 @@ class LiberviaCli:
|
|||
help=_("find page before this item"), metavar='ITEM_ID')
|
||||
rsm_page_group.add_argument(
|
||||
"--index", dest="rsm_index", type=int,
|
||||
help=_("index of the page to retrieve"))
|
||||
help=_("index of the first item to retrieve"))
|
||||
|
||||
|
||||
# MAM
|
||||
|
|
@ -424,6 +425,12 @@ class LiberviaCli:
|
|||
C.ORDER_BY_MODIFICATION],
|
||||
help=_("how items should be ordered"))
|
||||
|
||||
if flags[C.CACHE]:
|
||||
pubsub_group.add_argument(
|
||||
"-C", "--no-cache", dest="use_cache", action='store_false',
|
||||
help=_("don't use Pubsub cache")
|
||||
)
|
||||
|
||||
if not flags.all_used:
|
||||
raise exceptions.InternalError('unknown flags: {flags}'.format(
|
||||
flags=', '.join(flags.unused)))
|
||||
|
|
@ -1235,6 +1242,16 @@ class CommandBase(object):
|
|||
else:
|
||||
if order_by is not None:
|
||||
extra[C.KEY_ORDER_BY] = self.args.order_by
|
||||
|
||||
# Cache
|
||||
try:
|
||||
use_cache = self.args.use_cache
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
if not use_cache:
|
||||
extra[C.KEY_USE_CACHE] = use_cache
|
||||
|
||||
return data_format.serialise(extra)
|
||||
|
||||
def add_parser_options(self):
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ class Get(base.CommandBase):
|
|||
"get",
|
||||
use_verbose=True,
|
||||
use_pubsub=True,
|
||||
pubsub_flags={C.MULTI_ITEMS},
|
||||
pubsub_flags={C.MULTI_ITEMS, C.CACHE},
|
||||
use_output=C.OUTPUT_COMPLEX,
|
||||
extra_outputs=extra_outputs,
|
||||
help=_("get blog item(s)"),
|
||||
|
|
|
|||
|
|
@ -823,7 +823,7 @@ class Get(base.CommandBase):
|
|||
"get",
|
||||
use_output=C.OUTPUT_LIST_XML,
|
||||
use_pubsub=True,
|
||||
pubsub_flags={C.NODE, C.MULTI_ITEMS},
|
||||
pubsub_flags={C.NODE, C.MULTI_ITEMS, C.CACHE},
|
||||
help=_("get pubsub item(s)"),
|
||||
)
|
||||
|
||||
|
|
@ -835,7 +835,6 @@ class Get(base.CommandBase):
|
|||
help=_("subscription id"),
|
||||
)
|
||||
# TODO: a key(s) argument to select keys to display
|
||||
# TODO: add MAM filters
|
||||
|
||||
async def start(self):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ class Const(constants.Const):
|
|||
SINGLE_ITEM = "single_item" # only one item is allowed
|
||||
MULTI_ITEMS = "multi_items" # multiple items are allowed
|
||||
NO_MAX = "no_max" # don't add --max option for multi items
|
||||
CACHE = "cache" # add cache control flag
|
||||
|
||||
# ANSI
|
||||
A_HEADER = A.BOLD + A.FG_YELLOW
|
||||
|
|
|
|||
Loading…
Reference in a new issue