The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

peri-eg-completion - Do nothing, return args

VERSION

This document describes version 0.081 of peri-eg-completion (from Perl distribution Perinci-Examples-Bin-Classic), released on 2021-01-30.

SYNOPSIS

Usage:

 % peri-eg-completion [--a2-json=s] [--a2=s+] [--a3-json=s] [--a3=s+]
     [--arg0-json=s] [--arg0=s] [--config-path=path+]
     [--config-profile=profile] [--f0=s] [--f1=s] [--format-options=s]
     [--format=name] [--h1-json=s] [--h1 key=s] [--h2-json=s] [--h2 key=s]
     [--i0=s] [--i2=s] [--json] [--(no)naked-res] [--no-config] [--no-env]
     [--s1=s] [--s1b=s] [--s1c=s] [--s1d=s] [--s2=s] [--s3=s] [i1] [a1] ...

DESCRIPTION

This function is used to test argument completion.

OPTIONS

* marks required options.

Main options

--a1-json=s

Array of strings, where the string has "in" schema clause (JSON-encoded).

See --a1.

--a1=s@

Array of strings, where the string has "in" schema clause.

Completion library can perhaps complete from the `in` value and remember completed items when command-line option is repeated, e.g. in:

    --a1 <tab>

it will complete from any `in` value, but in:

    --a1 apple --a1 <tab>

it can exclude `apple` from the completion candidate.

Currently the completion library <pm:Perinci::Sub::Complete> does not do this though. Perhaps there can be an option to toggle this behavior.

Can be specified multiple times.

--a2-json=s

Array with element_completion routine that generate random letter (JSON-encoded).

See --a2.

--a2=s@

Array with element_completion routine that generate random letter.

Can be specified multiple times.

--a3-json=s

Array with element_completion routine that dies (JSON-encoded).

See --a3.

--a3=s@

Array with element_completion routine that dies.

See also `s3`.

Can be specified multiple times.

--arg0-json=s

Argument without any schema (JSON-encoded).

See --arg0.

--arg0=s

Argument without any schema.

--f0=s

Float with just "float" schema defined.

--f1=s

Float with xmin/xmax on the schema.

A completion library can attempt to provide some possible and incremental completion (e.g. if word is currently at one decimal digit like 1.2, it can provide completion of 1.20 .. 1.29).

--h1-json=s

Hash with "keys" and "allowed_keys" schema clauses and "element_completion" property (JSON-encoded).

See --h1.

--h1=s%

Hash with "keys" and "allowed_keys" schema clauses and "element_completion" property.

Each value is a name-value pair, use key=value syntax. Can be specified multiple times.

--h2-json=s

Hash with "element_completion" as well as "index_completion" properties (JSON-encoded).

See --h2.

--h2=s%

Hash with "element_completion" as well as "index_completion" properties.

Each value is a name-value pair, use key=value syntax. Can be specified multiple times.

--i0=s

Integer with just "int" schema defined.

--i1=s

Integer with min/xmax on the schema.

A completion library (like <pm:Perinci::Sub::Complete>) can generate a list of completion from the low end to the high end of the range, as long as it is not too long.

--i2=s

Integer with large range min/max on the schema.

Unlike in `i1`, a completion library probably won't generate a number sequence for this argument because they are considered too long (1000+ items).

--s1=s

String with possible values in "in" schema clause.

Valid values:

 ["apple","apricot","banana","grape","grapefruit","red date","red grape","green grape"]
--s1b=s

String with possible values in "in" schema clause, contains special characters.

Valid values:

 ["space: ","word containing spaces","single-quote: '","double-quote: \"","slash/","back\\slash","tab\t","word:with:colon","dollar \$sign","various parenthesis: [ ] { } ( )","tilde ~","backtick `","caret^","at\@","pound#","percent%","ampersand&","question?","wildcard*","comma,","semicolon;","pipe|","redirection > <","plus+"]

This argument is intended to test how special characters are escaped.

--s1c=s

String with examples in schema.

Example valid values:

 ["bar",{summary=>"foo",value=>"baz"}]
--s1d=s

String with examples in argument spec.

--s2=s

String with completion routine that generate random letter.

--s3=s

String with completion routine that dies.

Completion should not display error (except perhaps under debugging). It should just provide no completion.

Configuration options

--config-path=s

Set path to configuration file.

Can be specified multiple times.

--config-profile=s

Set configuration profile to use.

--no-config

Do not use any configuration file.

Environment options

--no-env

Do not read environment for default options.

Output options

--format-options=s

Pass options to formatter.

--format=s

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

Default value:

 undef
--json

Equivalent to --format=json-pretty.

--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]

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 peri-eg-completion peri-eg-completion

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 peri-eg-completion 'p/*/`peri-eg-completion`/'

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.

CONFIGURATION FILE

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

By default, these names are searched for configuration filenames (can be changed using --config-path): /home/s1/.config/peri-eg-completion.conf, /home/s1/peri-eg-completion.conf, or /etc/peri-eg-completion.conf.

All found files will be read and merged.

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

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

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

Finally, you can filter a section by environment variable using the filter env=CONDITION in section names. For example if you only want a section to be read if a certain environment variable is true: [env=SOMEVAR ...] or [SOMESECTION env=SOMEVAR ...]. If you only want a section to be read when the value of an environment variable has value equals something: [env=HOSTNAME=blink ...] or [SOMESECTION env=HOSTNAME=blink ...]. If you only want a section to be read when the value of an environment variable does not equal something: [env=HOSTNAME!=blink ...] or [SOMESECTION env=HOSTNAME!=blink ...]. If you only want a section to be read when an environment variable contains something: [env=HOSTNAME*=server ...] or [SOMESECTION env=HOSTNAME*=server ...]. Note that currently due to simplistic parsing, there must not be any whitespace in the value being compared because it marks the beginning of a new section filter or section name.

List of available configuration parameters:

 a1 (see --a1)
 a2 (see --a2)
 a3 (see --a3)
 arg0 (see --arg0)
 f0 (see --f0)
 f1 (see --f1)
 format (see --format)
 format_options (see --format-options)
 h1 (see --h1)
 h2 (see --h2)
 i0 (see --i0)
 i1 (see --i1)
 i2 (see --i2)
 naked_res (see --naked-res)
 s1 (see --s1)
 s1b (see --s1b)
 s1c (see --s1c)
 s1d (see --s1d)
 s2 (see --s2)
 s3 (see --s3)

ENVIRONMENT

PERI_EG_COMPLETION_OPT => str

Specify additional command-line options.

FILES

/home/s1/.config/peri-eg-completion.conf

/home/s1/peri-eg-completion.conf

/etc/peri-eg-completion.conf

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Perinci-Examples-Bin-Classic.

SOURCE

Source repository is at https://github.com/perlancar/perl-Perinci-Examples-Bin.

BUGS

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

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.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2021, 2020, 2015, 2014, 2013, 2012 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.