App-BraveUtils

 view release on metacpan or  search on metacpan

lib/App/BraveUtils.pm  view on Meta::CPAN

$SPEC{unpause_brave} = {
    v => 1.1,
    summary => "Unpause (resume, continue, kill -CONT) Brave",
    args => {
        %App::BrowserUtils::args_common,
    },
};
sub unpause_brave {
    App::BrowserUtils::_do_browser('unpause', 'brave', @_);
}

$SPEC{pause_and_unpause_brave} = {
    v => 1.1,
    summary => "Pause and unpause Brave alternately",
    description => $App::BrowserUtils::desc_pause_and_unpause,
    args => {
        %App::BrowserUtils::args_common,
        %App::BrowserUtils::argopt_periods,
    },
};
sub pause_and_unpause_brave {
    App::BrowserUtils::_do_browser('pause_and_unpause', 'brave', @_);
}

$SPEC{brave_has_processes} = {
    v => 1.1,
    summary => "Check whether Brave has processes",
    args => {
        %App::BrowserUtils::args_common,
        %App::BrowserUtils::argopt_quiet,
    },
};
sub brave_has_processes {
    App::BrowserUtils::_do_browser('has_processes', 'brave', @_);
}

$SPEC{brave_is_paused} = {
    v => 1.1,
    summary => "Check whether Brave is paused",
    description => <<'_',

Brave is defined as paused if *all* of its processes are in 'stop' state.

_
    args => {
        %App::BrowserUtils::args_common,
        %App::BrowserUtils::argopt_quiet,
    },
};
sub brave_is_paused {
    App::BrowserUtils::_do_browser('is_paused', 'brave', @_);
}

$SPEC{brave_is_running} = {
    v => 1.1,
    summary => "Check whether Brave is running",
    description => <<'_',

Brave is defined as running if there are some Brave processes that are *not*
in 'stop' state. In other words, if Brave has been started but is currently
paused, we do not say that it's running. If you want to check if Brave process
exists, you can use `ps_brave`.

_
    args => {
        %App::BrowserUtils::args_common,
        %App::BrowserUtils::argopt_quiet,
    },
};
sub brave_is_running {
    App::BrowserUtils::_do_browser('is_running', 'brave', @_);
}

$SPEC{terminate_brave} = {
    v => 1.1,
    summary => "Terminate Brave (by default with -KILL signal)",
    args => {
        %App::BrowserUtils::args_common,
        %App::BrowserUtils::argopt_signal,
    },
};
sub terminate_brave {
    App::BrowserUtils::_do_browser('terminate', 'brave', @_);
}

$SPEC{restart_brave} = {
    v => 1.1,
    summary => "Restart brave",
    args => {
        %App::BrowserUtils::argopt_brave_cmd,
        %App::BrowserUtils::argopt_quiet,
    },
    features => {
        dry_run => 1,
    },
};
sub restart_brave {
    App::BrowserUtils::restart_browsers(@_, restart_brave=>1);
}

$SPEC{start_brave} = {
    v => 1.1,
    summary => "Start brave if not already started",
    args => {
        %App::BrowserUtils::argopt_brave_cmd,
        %App::BrowserUtils::argopt_quiet,
    },
    features => {
        dry_run => 1,
    },
};
sub start_brave {
    App::BrowserUtils::start_browsers(@_, start_brave=>1);
}

1;
# ABSTRACT: Utilities related to Brave browser

__END__

=pod

lib/App/BraveUtils.pm  view on Meta::CPAN

used to determine which processes are the browser processes.

=item * B<exec_pat> => I<re_from_str>

Filter processes using regex against their exec.

If one of the C<*-pat> options are specified, then instead of the default
heuristic rules to find the browser processes, these C<*-pat> options are solely
used to determine which processes are the browser processes.

=item * B<fname_pat> => I<re_from_str>

Filter processes using regex against their fname.

If one of the C<*-pat> options are specified, then instead of the default
heuristic rules to find the browser processes, these C<*-pat> options are solely
used to determine which processes are the browser processes.

=item * B<pid_pat> => I<re_from_str>

Filter processes using regex against their pid.

If one of the C<*-pat> options are specified, then instead of the default
heuristic rules to find the browser processes, these C<*-pat> options are solely
used to determine which processes are the browser processes.

=item * B<quiet> => I<true>

(No description)

=item * B<users> => I<array[unix::uid::exists]>

Kill browser processes that belong to certain user(s) only.


=back

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code
(200 means OK, 4xx caller error, 5xx function error). Second element
($reason) is a string containing error message, or something like "OK" if status is
200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth
element (%result_meta) is called result metadata and is optional, a hash
that contains extra information, much like how HTTP response headers provide additional metadata.

Return value:  (any)



=head2 brave_is_running

Usage:

 brave_is_running(%args) -> [$status_code, $reason, $payload, \%result_meta]

Check whether Brave is running.

Brave is defined as running if there are some Brave processes that are I<not>
in 'stop' state. In other words, if Brave has been started but is currently
paused, we do not say that it's running. If you want to check if Brave process
exists, you can use C<ps_brave>.

This function is not exported.

Arguments ('*' denotes required arguments):

=over 4

=item * B<cmndline_pat> => I<re_from_str>

Filter processes using regex against their cmndline.

If one of the C<*-pat> options are specified, then instead of the default
heuristic rules to find the browser processes, these C<*-pat> options are solely
used to determine which processes are the browser processes.

=item * B<exec_pat> => I<re_from_str>

Filter processes using regex against their exec.

If one of the C<*-pat> options are specified, then instead of the default
heuristic rules to find the browser processes, these C<*-pat> options are solely
used to determine which processes are the browser processes.

=item * B<fname_pat> => I<re_from_str>

Filter processes using regex against their fname.

If one of the C<*-pat> options are specified, then instead of the default
heuristic rules to find the browser processes, these C<*-pat> options are solely
used to determine which processes are the browser processes.

=item * B<pid_pat> => I<re_from_str>

Filter processes using regex against their pid.

If one of the C<*-pat> options are specified, then instead of the default
heuristic rules to find the browser processes, these C<*-pat> options are solely
used to determine which processes are the browser processes.

=item * B<quiet> => I<true>

(No description)

=item * B<users> => I<array[unix::uid::exists]>

Kill browser processes that belong to certain user(s) only.


=back

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code
(200 means OK, 4xx caller error, 5xx function error). Second element
($reason) is a string containing error message, or something like "OK" if status is
200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth
element (%result_meta) is called result metadata and is optional, a hash
that contains extra information, much like how HTTP response headers provide additional metadata.



( run in 0.324 second using v1.01-cache-2.11-cpan-96521ef73a4 )