NAME

WWW::Hetzner::CLI::Role::WaitsForAction - CLI role that waits for a returned Action by default

VERSION

version 0.101

SYNOPSIS

package WWW::Hetzner::CLI::Cmd::Server::Cmd::Poweron;
use Moo;
use MooX::Cmd;
use MooX::Options protect_argv => 0;
with 'WWW::Hetzner::CLI::Role::WaitsForAction';

sub execute {
    my ($self, $args, $chain) = @_;
    my $action = $chain->[0]->cloud->servers->power_on($args->[0]);
    $self->handle_action($action);
    print $self->no_wait ? "Power-on requested.\n" : "Server powered on.\n";
}

DESCRIPTION

Shared behaviour for CLI subcommands whose controller call returns a WWW::Hetzner::Action (or an arrayref of them, as Firewall's plural methods do): wait for it to reach a terminal state before the command reports success, unless the user opted out with --no-wait.

Adds the --no-wait command line flag (via MooX::Options, so it is usable from any consuming class that itself uses MooX::Options) and "handle_action", the single point subcommands call after a mutating controller method returns.

wait

Boolean, defaults to true. Exposed on the command line as --wait / --no-wait (declared negativable so MooX::Options generates both forms from this one attribute -- an attribute literally named no_wait would collide with MooX::Options's own no- negation parsing and the --no-wait flag would never reach it). Command code should not need to read this directly; use "no_wait" or "handle_action" instead.

no_wait

$self->no_wait   # true when --no-wait was passed

The logical inverse of "wait", kept because it reads naturally at call sites and matches the flag's name.

handle_action

$self->handle_action($action);   # a single WWW::Hetzner::Action
$self->handle_action($actions);  # an arrayref of them (Firewall plural methods)

Waits for $action to reach a terminal state, unless --no-wait was given. Returns immediately, without waiting, when $action is undef or not something with a wait method (an entity whose creation emitted no action, e.g. an unmanaged placement group) and when --no-wait is set. An arrayref is handled element-wise: each waitable element is waited on in turn, in order, so a rule/target/service action list all reach a terminal state before the command reports completion.

SEE ALSO

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-www-hetzner/issues.

IRC

Join #kubernetes on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.