Added checkin/out subcommands to cli.
This commit is contained in:
parent
cf9295bb6a
commit
9d0b48da9a
44
bot_z/cli.py
44
bot_z/cli.py
|
@ -310,6 +310,50 @@ def logout_command(ctx: click.Context, name: T.Optional[str], force: bool) -> No
|
||||||
logger.info("Logout sent.")
|
logger.info("Logout sent.")
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command("checkin")
|
||||||
|
@click.option("-n", "--name", default=None, help="The instance to interact with.")
|
||||||
|
@click.option(
|
||||||
|
"-f",
|
||||||
|
"--force",
|
||||||
|
is_flag=True,
|
||||||
|
default=False,
|
||||||
|
help="Force logout, bypass login check.",
|
||||||
|
)
|
||||||
|
@click.pass_context
|
||||||
|
def checkin_command(ctx: click.Context, name: T.Optional[str], force: bool) -> None:
|
||||||
|
"""
|
||||||
|
Checks in on a logged in client.
|
||||||
|
"""
|
||||||
|
logger.debug("Sending the check in command down the pipe: %s", ctx.obj["fifo"])
|
||||||
|
name = _check_name(ctx.obj["lifo"], name)
|
||||||
|
logging.info("Checking in on instance: %s", name)
|
||||||
|
with open(ctx.obj["fifo"], "w") as fifo:
|
||||||
|
fifo.write(cmd_marshal(name=name, cmd="checkin", force=force))
|
||||||
|
logger.info("Check in sent.")
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command("checkout")
|
||||||
|
@click.option("-n", "--name", default=None, help="The instance to interact with.")
|
||||||
|
@click.option(
|
||||||
|
"-f",
|
||||||
|
"--force",
|
||||||
|
is_flag=True,
|
||||||
|
default=False,
|
||||||
|
help="Force logout, bypass login check.",
|
||||||
|
)
|
||||||
|
@click.pass_context
|
||||||
|
def checkout_command(ctx: click.Context, name: T.Optional[str], force: bool) -> None:
|
||||||
|
"""
|
||||||
|
Checks out on a logged in client and checked in client.
|
||||||
|
"""
|
||||||
|
logger.debug("Sending the check out command down the pipe: %s", ctx.obj["fifo"])
|
||||||
|
name = _check_name(ctx.obj["lifo"], name)
|
||||||
|
logging.info("Checking out on instance: %s", name)
|
||||||
|
with open(ctx.obj["fifo"], "w") as fifo:
|
||||||
|
fifo.write(cmd_marshal(name=name, cmd="checkout", force=force))
|
||||||
|
logger.info("Check out sent.")
|
||||||
|
|
||||||
|
|
||||||
@cli.command("reload")
|
@cli.command("reload")
|
||||||
@click.option("-n", "--name", default=None, help="The instance to interact with.")
|
@click.option("-n", "--name", default=None, help="The instance to interact with.")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
|
|
|
@ -126,6 +126,24 @@ def operator_logout(op: Operator, force: bool) -> None:
|
||||||
logger.info("Logout done.")
|
logger.info("Logout done.")
|
||||||
|
|
||||||
|
|
||||||
|
def operator_checkin(op: Operator, force: bool) -> None:
|
||||||
|
"""
|
||||||
|
Instructs the operator to perform the check in.
|
||||||
|
"""
|
||||||
|
logger.debug("Performing check in...")
|
||||||
|
op.checkin()
|
||||||
|
logger.info("Check in done.")
|
||||||
|
|
||||||
|
|
||||||
|
def operator_checkout(op: Operator, force: bool) -> None:
|
||||||
|
"""
|
||||||
|
Instructs the operator to perform the check out.
|
||||||
|
"""
|
||||||
|
logger.debug("Performing check out...")
|
||||||
|
op.checkout()
|
||||||
|
logger.info("Check out done.")
|
||||||
|
|
||||||
|
|
||||||
def daemon_process(
|
def daemon_process(
|
||||||
fifo_path: str,
|
fifo_path: str,
|
||||||
working_dir: str,
|
working_dir: str,
|
||||||
|
@ -184,6 +202,8 @@ def daemon_process(
|
||||||
"status": operator_status,
|
"status": operator_status,
|
||||||
"login": operator_login,
|
"login": operator_login,
|
||||||
"logout": operator_logout,
|
"logout": operator_logout,
|
||||||
|
"checkin": operator_checkin,
|
||||||
|
"checkout": operator_checkout,
|
||||||
}
|
}
|
||||||
logger.debug("command map defined")
|
logger.debug("command map defined")
|
||||||
|
|
||||||
|
@ -240,6 +260,12 @@ def listen_client(
|
||||||
elif cmd["cmd"] == "logout":
|
elif cmd["cmd"] == "logout":
|
||||||
logger.debug("Received command: logout")
|
logger.debug("Received command: logout")
|
||||||
cmd_map["logout"](op, cmd["force"])
|
cmd_map["logout"](op, cmd["force"])
|
||||||
|
elif cmd["cmd"] == "checkin":
|
||||||
|
logger.debug("Received command: checkin")
|
||||||
|
cmd_map["checkin"](op, cmd["force"])
|
||||||
|
elif cmd["cmd"] == "checkout":
|
||||||
|
logger.debug("Received command: checkout")
|
||||||
|
cmd_map["checkout"](op, cmd["force"])
|
||||||
|
|
||||||
|
|
||||||
def listen_commands(
|
def listen_commands(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user