riap - Riap command-line client shell
version 0.383
% riap --help % riap [opts] <uri>
Invoking:
# URI defaults to 'pl:/', which is the local Perl realm % riap # ditto, but specify initial "pwd" % riap /Calendar/Indonesia/Holiday % riap pl:/Calendar/Indonesia/Holiday # access remote API starting point % riap https://cpanlists.org/api/ % riap http://gudangapi.com/ga/
An example session:
riap> pwd / riap> cd /spanel/api riap> ls account/ disk_usage/ mysql/ pgsql/ plan/ ... riap> cd account/shared/query riap> pwd /spanel/api/account/shared/query riap> ls -l create_account function delete_accounts function suspend_account function unsuspend_account function # execute a Riap function like it is an executable program riap> list_accounts --nodisabled --nomigrated andi budi jamal titin ujang riap> ../modify/delete_account --help riap> exit
riap is a Riap client in the form of a simple interactive command-line shell (as opposed to Perinci::Access which is a Perl library, or peri-run and peri-access which are non-interactive command-line interfaces). This riap shell provides a convenient way to explore API services which use the Riap protocol or explore Perl modules which have Rinci metadata.
riap
Example API services that you can (or will be able to) test this with:
cpanlists.org at https://cpanlists.org/api/
gudangdata.org at https://gudangdata.org/gd/
gudangapi.com at https://gudangapi.com/ga/
Any server using the Spanel control panel software
The API daemon listens at the Unix socket at /var/run/spanel/apid.sock or at TCP https://localhost:1010.
/var/run/spanel/apid.sock
https://localhost:1010
Example Perl libraries you can test this with (you need to install them first): Text::sprintfn, Git::Bunch, Calendar::Indonesia::Holiday, Perinci::Examples. Try to search for CPAN distributions which specify Rinci as their prerequisites.
Within the shell, you can browse packages and functions as if they were directories and executable files (using commands like cd, ls, pwd). You can call functions like they were command-line programs, by passing command-line parameters for function arguments.
cd
ls
pwd
See "COMMANDS" for list of known commands.
--help
Show short help message.
--user=S
Supply HTTP authentication user. You can also set this via environment PERINCI_HTTP_USER (see Perinci::Access for more details) or from inside the shell via set user <S>.
set user <S>
--password=S
Supply HTTP authentication password. You can also set this via environment PERINCI_HTTP_PASSWORD (see Perinci::Access for more details) or from inside the shell via set password <S>.
set password <S>
Using the command-line option is not recommended because of security issue (command-line commands/arguments are usually visible to all users on the system via commands like ps).
Display help message.
Print the current directory (package). When you first enter the shell, current directory is set to /.
/
Change directory (package). You can use relative notation (../foo) like in a Unix filesystem.
../foo
Perform meta Riap request and format the result as text.
meta
List of content of directory (package) or other code entities by performing list Riap request. If path is not specified, will list the current directory (package).
list
path
Options:
--long (-l)
Add detail => 1 to the Riap request, which will return more details.
detail => 1
Alias for ls.
Perform info Riap request on an entity at path.
info
Perform Riap request to a code entity at path. Extra request keys can be specified in extra.
extra
Examples:
riap> request call /Package/Sub/somefunc '{"args":{"a":1, "b":2}}' riap> request list /Package/Sub/somefunc '{"detail":1}'
Perform call Riap request. Note that call command is actually optional: the shell performs call requests by default on paths.
call
riap> call /Package/Sub/somefunc '{"foo":1, "bar":2}'
which is equivalent to:
riap> /Package/Sub/somefunc --foo 1 --bar 2
If invoked without any argument, will list all known settings. If name is specified but value is not, will show value for that particular setting. If name and value is both specified, will set a setting's value.
name
value
Settings are configuration and regulate how the shell behaves.
For HTTP authentication.
text
Set output format for command results. The same formatting is used by Perinci::CmdLine. See that module or Perinci::Result::Format for more details.
Whether to show raw Riap requests and responses being sent to/received from the server.
Whether to show debugging information when doing tab completion.
Whether to show how long a command takes.
Number of seconds to cache Riap results from server, to speed up things like tab completion.
It looks to be an issue with Term::ReadLine::Perl. Try installing Term::ReadLine::Gnu instead.
riap is meant to be a simple shell, not a full-blown Unix shell. Besides, a syntax like this:
riap> call /Package/Sub/somefunc > /path/to/file
will be confusing since paths map to code entity URIs in riap, not filesystem paths.
But something like a setting might be implemented if this is a popular feature request.
Again, riap is meant to be a simple shell, not a full-blown Unix shell. To do those things, you are better off using peri-run or peri-access and incorporate them in a Unix shell script. For example you can write these two short scripts:
# list-accounts #!/bin/sh peri-access call https://yourservice.com/api/Account/list # delete-account (input sanitizing is left as exercise for the readers) #!/bin/sh peri-access call "https://yourservice.com/api/Account/delete?account=$1"
and then write:
# delete all accounts for a in `list-accounts`; do delete-account "$a" done
If set, can be used to set user setting (but priority lower than command-line option --user).
user
--user
If set, can be used to set password setting (but priority lower than command-line option --password). This is usually more secure to use than command-line option, because command-line option is usually visible from all users on the system via commands like ps.
password
--password
ps
~/.riap_history
Specify location of command history file. Like in shells, can be set to empty string to disable history loading/saving.
~/.riaprc
Specify location of settings file.
Command history file.
Settings file (IOD format).
perlancar <perlancar@cpan.org>
This software is copyright (c) 2020, 2019, 2017, 2016, 2015, 2014, 2013 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.
To install App::riap, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::riap
CPAN shell
perl -MCPAN -e shell install App::riap
For more information on module installation, please visit the detailed CPAN module installation guide.