our $DATE = '2020-07-09'; # DATE
our $DIST = 'Progress-Any-Examples'; # DIST
our $VERSION = '0.005'; # VERSION

use 5.010001;
use strict;
use warnings;

use Progress::Any;
use Progress::Any::Output -task=>'x', 'TermProgressBarColor', freq=>0.1;
use Time::HiRes qw(sleep);

my $progress_x = Progress::Any->get_indicator(task => "x");
my $progress_y = Progress::Any->get_indicator(task => "y");
my $progress   = Progress::Any->get_indicator(task => "" , target=>0); # to say that we only have subtasks x and y and no target on

my ($target_x, $target_y) = @ARGV;
$progress_x->target($target_x) if $target_x;
$progress_y->target($target_y) if $target_y;

for (1.. $target_x // int(15*rand)+7) {
    $progress_x->update(message => "Doing task x $_/".($target_x // "?"));
    sleep 0.2;
$progress_x->finish(message => "Finished doing task x"); # optional
sleep 2;

for (1.. $target_y // int(15*rand)+7) {
    $progress_y->update(message => "Doing task y $_/".($target_y // "?"));
    sleep 0.2;
$progress_y->finish(message => "Finished doing task y"); # optional
sleep 2;

$progress->finish; # required to clean the progress bar

# ABSTRACT: Two tasks, progress bar for the whole two tasks
# PODNAME: progress-any-eg-progressbar-03-progressbar-on-subtask



=encoding UTF-8

=head1 NAME

progress-any-eg-progressbar-03-progressbar-on-subtask - Two tasks, progress bar for the whole two tasks

=head1 VERSION

This document describes version 0.005 of progress-any-eg-progressbar-03-progressbar-on-subtask (from Perl distribution Progress-Any-Examples), released on 2020-07-09.


 % progress-any-eg-progressbar-03-progressbar-on-subtask [target_x] [target_y]


This example is exactly like the previous example
L<progress-any-eg-progressbar-02-multiple-tasks-one-progressbar>, except that we
are showing the progress bar of only one subtask, 'x'.

Notice that when task 'x' is finished, the progress bar is immediately cleared.
And the progress on task 'y' is not shown.


Please visit the project's homepage at L<https://metacpan.org/release/Progress-Any-Examples>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-Progress-Any-Examples>.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Progress-Any-Examples>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired

=head1 AUTHOR

perlancar <perlancar@cpan.org>


This software is copyright (c) 2020 by perlancar@cpan.org.

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