App-TextFragmentUtils

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.017.
Changes
LICENSE
MANIFEST
META.json
META.yml
Makefile.PL
README
dist.ini
lib/App/TextFragmentUtils.pm
script/get-fragment
script/list-fragments
t/00-compile.t
t/author-critic.t
t/author-pod-coverage.t
t/author-pod-syntax.t
t/release-rinci.t
weaver.ini

META.json  view on Meta::CPAN

      }
   },
   "version" : "0.002",
   "x_Dist_Zilla" : {
      "perl" : {
         "version" : "5.034000"
      },
      "plugins" : [
         {
            "class" : "Dist::Zilla::Plugin::GenPericmdScript",
            "name" : "GenPericmdScript list-fragments",
            "version" : "0.423"
         },
         {
            "class" : "Dist::Zilla::Plugin::GenPericmdScript",
            "name" : "GenPericmdScript get-fragment",
            "version" : "0.423"
         },
         {
            "class" : "Dist::Zilla::Plugin::InsertExecsList",
            "name" : "InsertExecsList",
            "version" : "0.02"
         },
         {
            "class" : "Dist::Zilla::Plugin::PERLANCAR::CheckPendingRelease",
            "name" : "@Author::PERLANCAR/PERLANCAR::CheckPendingRelease",

META.yml  view on Meta::CPAN

  bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=App-TextFragmentUtils
  homepage: https://metacpan.org/release/App-TextFragmentUtils
  repository: git://github.com/perlancar/perl-App-TextFragmentUtils.git
version: '0.002'
x_Dist_Zilla:
  perl:
    version: '5.034000'
  plugins:
    -
      class: Dist::Zilla::Plugin::GenPericmdScript
      name: 'GenPericmdScript list-fragments'
      version: '0.423'
    -
      class: Dist::Zilla::Plugin::GenPericmdScript
      name: 'GenPericmdScript get-fragment'
      version: '0.423'
    -
      class: Dist::Zilla::Plugin::InsertExecsList
      name: InsertExecsList
      version: '0.02'
    -
      class: Dist::Zilla::Plugin::PERLANCAR::CheckPendingRelease
      name: '@Author::PERLANCAR/PERLANCAR::CheckPendingRelease'
      version: '0.001'
    -

Makefile.PL  view on Meta::CPAN

use ExtUtils::MakeMaker;

my %WriteMakefileArgs = (
  "ABSTRACT" => "CLI utilities related to Text::Fragment",
  "AUTHOR" => "perlancar <perlancar\@cpan.org>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "App-TextFragmentUtils",
  "EXE_FILES" => [
    "script/get-fragment",
    "script/list-fragments"
  ],
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.010001",
  "NAME" => "App::TextFragmentUtils",
  "PREREQ_PM" => {
    "Data::Clone" => 0,
    "Data::Sah::Compiler::perl::TH::str" => 0,
    "Data::Sah::Filter::perl::Path::expand_tilde_when_on_unix" => 0,
    "Data::Sah::Filter::perl::Path::strip_slashes_when_on_unix" => 0,
    "File::Slurper" => 0,

README  view on Meta::CPAN

NAME
    App::TextFragmentUtils - CLI utilities related to Text::Fragment

VERSION
    This document describes version 0.002 of App::TextFragmentUtils (from
    Perl distribution App-TextFragmentUtils), released on 2021-05-25.

DESCRIPTION
    This distributions provides the following command-line utilities related
    to text fragment:

    *   get-fragment

    *   list-fragments

FUNCTIONS
  get_fragment
    Usage:

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

    Get fragment with a certain ID in text.

    If there are multiple occurences of the fragment with the same ID ,

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   comment_style => *str* (default: "shell")

        Comment style.

    *   filename* => *filename*

README  view on Meta::CPAN


    First element ($status_code) is an integer containing HTTP status code
    (200 means OK, 4xx caller error, 5xx function error). Second element
    ($reason) is a string containing error message, or "OK" if status is
    200. Third element ($payload) is optional, the actual result. Fourth
    element (%result_meta) is called result metadata and is optional, a hash
    that contains extra information.

    Return value: Fragment (array)

    Will return status 200 if fragment is found. Result will be a hash with
    the following keys: "raw" (string), "payload" (string), "attrs" (hash),
    "id" (string, can also be found in attributes).

    Return 404 if fragment is not found.

  list_fragments
    Usage:

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

    List fragments in text.

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   comment_style => *str* (default: "shell")

        Comment style.

    *   filename* => *filename*

README  view on Meta::CPAN


    Returns an enveloped result (an array).

    First element ($status_code) is an integer containing HTTP status code
    (200 means OK, 4xx caller error, 5xx function error). Second element
    ($reason) is a string containing error message, or "OK" if status is
    200. Third element ($payload) is optional, the actual result. Fourth
    element (%result_meta) is called result metadata and is optional, a hash
    that contains extra information.

    Return value: List of fragments (array)

    Will return status 200 if operation is successful. Result will be an
    array of fragments, where each fragment is a hash containing these keys:
    "raw" (string), "payload" (string), "attrs" (hash), "id" (string, can
    also be found in attributes).

HOMEPAGE
    Please visit the project's homepage at
    <https://metacpan.org/release/App-TextFragmentUtils>.

SOURCE
    Source repository is at
    <https://github.com/perlancar/perl-App-TextFragmentUtils>.

dist.ini  view on Meta::CPAN

version=0.002

name=App-TextFragmentUtils

[GenPericmdScript / GenPericmdScript list-fragments]
url=/App/TextFragmentUtils/list_fragments

[GenPericmdScript / GenPericmdScript get-fragment]
url=/App/TextFragmentUtils/get_fragment

;[GenPericmdScript / GenPericmdScript set-fragment-attrs]
;url=/App/TextFragmentUtils/set_fragment_attrs

;[GenPericmdScript / GenPericmdScript insert-fragment]
;url=/App/TextFragmentUtils/insert_fragment

;[GenPericmdScript / GenPericmdScript delete-fragment]
;url=/App/TextFragmentUtils/delete_fragments

[InsertExecsList]

[@Author::PERLANCAR]
:version=0.603

[Prereqs / TestRequires]
;Test::More=0.98

[Prereqs]

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

    if ($filename eq '-') {
        local $/;
        $text = <STDIN>;
    } else {
        $text = read_text($filename);
    }
    $tf_args{text} = $text;
    \%tf_args;
}

$SPEC{list_fragments} = do {
    my $meta = clone $Text::Fragment::SPEC{list_fragments};
    delete $meta->{args}{text};
    $meta->{args}{filename} = $filename_arg;
    $meta;
};
sub list_fragments {
    my %args = @_;

    my $tf_args = _get_tf_args(%args);
    Text::Fragment::list_fragments(%$tf_args);
}

$SPEC{get_fragment} = do {
    my $meta = clone $Text::Fragment::SPEC{get_fragment};
    delete $meta->{args}{text};
    $meta->{args}{filename} = $filename_arg;
    $meta;
};
sub get_fragment {
    my %args = @_;

    my $tf_args = _get_tf_args(%args);
    Text::Fragment::get_fragment(%$tf_args);
}

1;
# ABSTRACT: CLI utilities related to Text::Fragment

__END__

=pod

=encoding UTF-8

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


App::TextFragmentUtils - CLI utilities related to Text::Fragment

=head1 VERSION

This document describes version 0.002 of App::TextFragmentUtils (from Perl distribution App-TextFragmentUtils), released on 2021-05-25.

=head1 DESCRIPTION

This distributions provides the following command-line utilities related to
text fragment:

=over

=item * L<get-fragment>

=item * L<list-fragments>

=back

=head1 FUNCTIONS


=head2 get_fragment

Usage:

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

Get fragment with a certain ID in text.

If there are multiple occurences of the fragment with the same ID ,

This function is not exported.

Arguments ('*' denotes required arguments):

=over 4

=item * B<comment_style> => I<str> (default: "shell")

Comment style.

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

First element ($status_code) is an integer containing HTTP status code
(200 means OK, 4xx caller error, 5xx function error). Second element
($reason) is a string containing error message, or "OK" if status is
200. Third element ($payload) is optional, the actual result. Fourth
element (%result_meta) is called result metadata and is optional, a hash
that contains extra information.

Return value: Fragment (array)


Will return status 200 if fragment is found. Result will be a hash with the
following keys: C<raw> (string), C<payload> (string), C<attrs> (hash), C<id>
(string, can also be found in attributes).

Return 404 if fragment is not found.



=head2 list_fragments

Usage:

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

List fragments in text.

This function is not exported.

Arguments ('*' denotes required arguments):

=over 4

=item * B<comment_style> => I<str> (default: "shell")

Comment style.

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


Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP status code
(200 means OK, 4xx caller error, 5xx function error). Second element
($reason) is a string containing error message, or "OK" if status is
200. Third element ($payload) is optional, the actual result. Fourth
element (%result_meta) is called result metadata and is optional, a hash
that contains extra information.

Return value: List of fragments (array)


Will return status 200 if operation is successful. Result will be an array of
fragments, where each fragment is a hash containing these keys: C<raw> (string),
C<payload> (string), C<attrs> (hash), C<id> (string, can also be found in
attributes).

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-TextFragmentUtils>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-TextFragmentUtils>.

script/get-fragment  view on Meta::CPAN

#!perl

# Note: This script is a CLI for Riap function /App/TextFragmentUtils/get_fragment
# and generated automatically using Perinci::CmdLine::Gen version 0.498

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2021-05-25'; # DATE
our $DIST = 'App-TextFragmentUtils'; # DIST
our $VERSION = '0.002'; # VERSION

use 5.010001;
use strict;
use warnings;

use Perinci::CmdLine::Any;

my $cmdline = Perinci::CmdLine::Any->new(
    url => "/App/TextFragmentUtils/get_fragment",
    program_name => "get-fragment",
);

$cmdline->run;

# ABSTRACT: Get fragment with a certain ID in text
# PODNAME: get-fragment

__END__

=pod

=encoding UTF-8

=head1 NAME

get-fragment - Get fragment with a certain ID in text

=head1 VERSION

This document describes version 0.002 of get-fragment (from Perl distribution App-TextFragmentUtils), released on 2021-05-25.

=head1 SYNOPSIS

Usage:

 % get-fragment [--comment-style=s] [--config-path=path | -c]
     [--config-profile=profile | -P] [--format=name] [--id=s] [--json]
     [--label=s] [--(no)naked-res] [--no-config | -C] [--no-env]
     [--page-result[=program]] [--view-result[=program]] <filename>

=head1 DESCRIPTION

If there are multiple occurences of the fragment with the same ID ,

=head1 OPTIONS

C<*> marks required options.

=head2 Main options

=over

=item B<--comment-style>=I<s>

script/get-fragment  view on Meta::CPAN


=head1 COMPLETION

This script has shell tab completion capability with support for several
shells.

=head2 bash

To activate bash completion for this script, put:

 complete -C get-fragment get-fragment

in your bash startup (e.g. F<~/.bashrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.

It is recommended, however, that you install modules using L<cpanm-shcompgen>
which can activate shell completion for scripts immediately.

=head2 tcsh

To activate tcsh completion for this script, put:

 complete get-fragment 'p/*/`get-fragment`/'

in your tcsh startup (e.g. F<~/.tcshrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.

It is also recommended to install L<shcompgen> (see above).

=head2 other shells

For fish and zsh, install L<shcompgen> as described above.

=head1 CONFIGURATION FILE

This script can read configuration files. Configuration files are in the format of L<IOD>, which is basically INI with some extra features.

By default, these names are searched for configuration filenames (can be changed using C<--config-path>): F<~/.config/get-fragment.conf>, F<~/get-fragment.conf>, or F</etc/get-fragment.conf>.

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

script/get-fragment  view on Meta::CPAN

 naked_res (see --naked-res)

=head1 ENVIRONMENT

=head2 GET_FRAGMENT_OPT => str

Specify additional command-line options.

=head1 FILES

F<~/.config/get-fragment.conf>

F<~/get-fragment.conf>

F</etc/get-fragment.conf>

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-TextFragmentUtils>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-TextFragmentUtils>.

=head1 BUGS

script/list-fragments  view on Meta::CPAN

#!perl

# Note: This script is a CLI for Riap function /App/TextFragmentUtils/list_fragments
# and generated automatically using Perinci::CmdLine::Gen version 0.498

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2021-05-25'; # DATE
our $DIST = 'App-TextFragmentUtils'; # DIST
our $VERSION = '0.002'; # VERSION

use 5.010001;
use strict;
use warnings;

use Perinci::CmdLine::Any;

my $cmdline = Perinci::CmdLine::Any->new(
    url => "/App/TextFragmentUtils/list_fragments",
    program_name => "list-fragments",
);

$cmdline->run;

# ABSTRACT: List fragments in text
# PODNAME: list-fragments

__END__

=pod

=encoding UTF-8

=head1 NAME

list-fragments - List fragments in text

=head1 VERSION

This document describes version 0.002 of list-fragments (from Perl distribution App-TextFragmentUtils), released on 2021-05-25.

=head1 SYNOPSIS

Usage:

 % list-fragments [--comment-style=s] [--config-path=path | -c]
     [--config-profile=profile | -P] [--format=name] [--json] [--label=s]
     [--(no)naked-res] [--no-config | -C] [--no-env]
     [--page-result[=program]] [--view-result[=program]] <filename>

=head1 OPTIONS

C<*> marks required options.

=head2 Main options

script/list-fragments  view on Meta::CPAN


=head1 COMPLETION

This script has shell tab completion capability with support for several
shells.

=head2 bash

To activate bash completion for this script, put:

 complete -C list-fragments list-fragments

in your bash startup (e.g. F<~/.bashrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.

It is recommended, however, that you install modules using L<cpanm-shcompgen>
which can activate shell completion for scripts immediately.

=head2 tcsh

To activate tcsh completion for this script, put:

 complete list-fragments 'p/*/`list-fragments`/'

in your tcsh startup (e.g. F<~/.tcshrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.

It is also recommended to install L<shcompgen> (see above).

=head2 other shells

For fish and zsh, install L<shcompgen> as described above.

=head1 CONFIGURATION FILE

This script can read configuration files. Configuration files are in the format of L<IOD>, which is basically INI with some extra features.

By default, these names are searched for configuration filenames (can be changed using C<--config-path>): F<~/.config/list-fragments.conf>, F<~/list-fragments.conf>, or F</etc/list-fragments.conf>.

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

script/list-fragments  view on Meta::CPAN

 naked_res (see --naked-res)

=head1 ENVIRONMENT

=head2 LIST_FRAGMENTS_OPT => str

Specify additional command-line options.

=head1 FILES

F<~/.config/list-fragments.conf>

F<~/list-fragments.conf>

F</etc/list-fragments.conf>

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-TextFragmentUtils>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-TextFragmentUtils>.

=head1 BUGS

t/00-compile.t  view on Meta::CPAN


use Test::More;

plan tests => 3 + ($ENV{AUTHOR_TESTING} ? 1 : 0);

my @module_files = (
    'App/TextFragmentUtils.pm'
);

my @scripts = (
    'script/get-fragment',
    'script/list-fragments'
);

# no fake home requested

my @switches = (
    -d 'blib' ? '-Mblib' : '-Ilib',
);

use File::Spec;
use IPC::Open3;

t/author-critic.t  view on Meta::CPAN

}


use strict;
use warnings;

# this test was generated with Dist::Zilla::Plugin::Test::Perl::Critic::Subset 3.001.005

use Test::Perl::Critic (-profile => "") x!! -e "";

my $filenames = ['lib/App/TextFragmentUtils.pm','script/get-fragment','script/list-fragments'];
unless ($filenames && @$filenames) {
    $filenames = -d "blib" ? ["blib"] : ["lib"];
}

all_critic_ok(@$filenames);



( run in 1.246 second using v1.01-cache-2.11-cpan-b16cb0d3907 )