#!/usr/bin/perl
use v5.26;

use App::url;

=encoding utf8

=head1 NAME

url - format a URL according to a sprintf-like template

=head1 SYNOPSIS

	# format as just the host
	$ url '%H' http://www.example.com/a/b/c
	www.example.com

	# handle more than one.
	$ url '%H' http://www.example.com/a/b/c http://www.github.com
	www.example.com
	www.github.com

	$ url '%P' http://www.example.com/a/b/c
	/a/b/c

=head1 DESCRIPTION

Decompose the URL and reformat it according to a template.

=head2 The formats

=over 4

=item * C<%a> - the path,

=item * C<%f> - the fragment

=item * C<%h> - the hostname

=item * C<%h> - the hostname in punycode

=item * C<%P> - the password of the userinfo portion

=item * C<%p> - the port

=item * C<%q> - the query string

=item * C<%s> - the scheme

=item * C<%u> - the complete URL

=item * C<%U> - the username of the userinfo portion

=back

=head1 COPYRIGHT

Copyright © 2020, brian d foy, all rights reserved.

=head1 LICENSE

You can use this code under the terms of the Artistic License 2.

=cut

use Encode qw(decode_utf8);
@ARGV = map { decode_utf8($_, 1) } @ARGV;

say join "\n", App::url->run( @ARGV )->@*;
