The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

seq-pericmd - Rinci-/Perinci::CmdLine-based "seq"-like CLI utility

VERSION

This document describes version 0.050 of seq-pericmd (from Perl distribution App-SeqPericmd), released on 2021-07-17.

SYNOPSIS

Usage:

% seq-pericmd [--equal-width|-w] [--format=name|--json] [--header=str] [--limit=int] [--(no)naked-res] [--number-format=str] [--page-result[=program]|--view-result[=program]] [-f=str] [-n=int] -- <from> [to] [increment]

Examples:

Generate whole numbers from 1 to 10 (1, 2, ..., 10):

 % seq-pericmd 1 10

Generate odd numbers from 1 to 10 (1, 3, 5, 7, 9):

 % seq-pericmd 1 10 2

Generate 1, 1.5, 2, 2.5, ..., 10:

 % seq-pericmd 1 10 -i 0.5

Generate stream 1, 1.5, 2, 2.5, ...:

 % seq-pericmd 1 -i 0.5

Generate 01, 02, ..., 10:

 % seq-pericmd 1 10 -w

Generate 0001, 0002, ..., 0010:

 % seq-pericmd 1 10 -f "%04s"

Generate -10, -9, -8, -7, -6 (limit 5 numbers):

 % seq-pericmd --from -10 --to 0 -n 5

Use with fsql:

 % seq-pericmd 1 100 --header num | fsql --add-tsv - --add-csv data.csv 'SELECT num, data1 FROM stdin LEFT JOIN data ON stdin.num=data.num'

DESCRIPTION

This utility is similar to Unix seq command, with a few differences: some differences in option names, JSON output, allow infinite stream (when to is not specified).

OPTIONS

* marks required options.

Main options

--equal-width, -w

Equalize width by padding with leading zeros.

--from=s*

Can also be specified as the 1st command-line argument.

--header=s

Add a header row.

--increment=s, -i

Default value:

 1

Can also be specified as the 3rd command-line argument.

--limit=s, -n

Only generate a certain amount of numbers.

--number-format=s, -f

sprintf() format for each number.

--to=s

Can also be specified as the 2nd command-line argument.

Output options

--format=s

Choose output format, e.g. json, text.

Default value:

 undef
--json

Set output format to json.

--naked-res

When outputing as JSON, strip result envelope.

Default value:

 0

By default, when outputing as JSON, the full enveloped result is returned, e.g.:

    [200,"OK",[1,2,3],{"func.extra"=>4}]

The reason is so you can get the status (1st element), status message (2nd element) as well as result metadata/extra result (4th element) instead of just the result (3rd element). However, sometimes you want just the result, e.g. when you want to pipe the result for more post-processing. In this case you can use `--naked-res` so you just get:

    [1,2,3]
--page-result

Filter output through a pager.

--view-result

View output using a viewer.

Other options

--help, -h, -?

Display help message and exit.

--version, -v

Display program's version and exit.

COMPLETION

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

bash

To activate bash completion for this script, put:

 complete -C seq-pericmd seq-pericmd

in your bash startup (e.g. ~/.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 cpanm-shcompgen which can activate shell completion for scripts immediately.

tcsh

To activate tcsh completion for this script, put:

 complete seq-pericmd 'p/*/`seq-pericmd`/'

in your tcsh startup (e.g. ~/.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 shcompgen (see above).

other shells

For fish and zsh, install shcompgen as described above.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/App-SeqPericmd.

SOURCE

Source repository is at https://github.com/perlancar/perl-App-SeqPericmd.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-SeqPericmd

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 feature.

SEE ALSO

seq.

seq-pl.

seq-intrange.

seq-numseq.

numseq.

primes.

primes.pl.

primes-pericmd.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2021, 2016, 2015 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.