Jp/en

De Goffiwiki
Aller à : navigation, rechercher


Introduction

Jp is Salut à Toi's command-line interface. It allows one to send or receive files directly from a shell, pipe commands to or from XMPP, use XMPP easily in a script, etc.

The following sub-commands are supported:

message
messages handling
param
Save/load parameters template
file
File sending/receiving
profile
Profile commands
roster
Manage an entity's roster
info
Get various pieces of information on entities
pipe
stream piping through XMPP
blog
blog/microblog management
ad-hoc
Ad-hoc commands
bookmarks
manage bookmarks


For getting some help about a command, type e.g.:

 jp message --help

If the command message contains subcommands, this will only list those subcommands without giving a lot of information about them. Then you can type e.g:

 jp message send --help

This will display all the arguments that you need to know in order to use the subcommand send.

Examples of usage

  • Send a message to a contact:
 cat "Salut" > test
 jp message send -p souliane@diekulturvermittlung.at -c --pwd MyPassWord souliane@libervia.org < test

Explanation : souliane@diekulturvermittlung.at sends a chat message with the content of the file test to souliane@libervia.org. The argument -c means "connect the profile, if not already connected". MyPassWord is the password of souliane@diekulturvermittlung.at (and you ought to think twice before using this option because it makes your password directly readable from the screen and it also saves it to your shell history).

Of course you can also use the pipe operator to feed your messages:

 env | grep PYTHON | jp message send -p souliane@diekulturvermittlung.at -c --pwd MyPassWord souliane@libervia.org

Send a file to a contact

 jp file send -p souliane@diekulturvermittlung.at -c --pwd MyPassWord test souliane@libervia.org

This will send the file test to the contact. This is completely different than jp message send as you really send a file and not a message, your contact can choose in which directory it will be saved on his drive. You can send binary file such as images or videos.


Receive files

The following command allows to receive a file in the /tmp directory.

$ jp file receive -p sat --path /tmp

Get information about a server

$ jp info version libervia.org
Client name: Prosody
Client version: 0.10.0
Operating System: Linux

Get disco information

Query a Server

$ jp info disco libervia.org

Features

http://jabber.org/protocol/commands
http://jabber.org/protocol/disco#info
http://jabber.org/protocol/disco#items
http://jabber.org/protocol/pubsub#auto-create
http://jabber.org/protocol/pubsub#config-node
http://jabber.org/protocol/pubsub#create-nodes
http://jabber.org/protocol/pubsub#delete-any
http://jabber.org/protocol/pubsub#delete-nodes
http://jabber.org/protocol/pubsub#groupblog
http://jabber.org/protocol/pubsub#instant-nodes
http://jabber.org/protocol/pubsub#item-ids
http://jabber.org/protocol/pubsub#meta-data
http://jabber.org/protocol/pubsub#outcast-affiliation
http://jabber.org/protocol/pubsub#persistent-items
http://jabber.org/protocol/pubsub#publish
http://jabber.org/protocol/pubsub#publisher-affiliation
http://jabber.org/protocol/pubsub#purge-nodes
http://jabber.org/protocol/pubsub#retract-items
http://jabber.org/protocol/pubsub#retrieve-affiliations
http://jabber.org/protocol/pubsub#retrieve-default
http://jabber.org/protocol/pubsub#retrieve-items
http://jabber.org/protocol/pubsub#retrieve-subscriptions
http://jabber.org/protocol/pubsub#subscribe
jabber:iq:last
jabber:iq:private
jabber:iq:roster
jabber:iq:time
jabber:iq:version
msgoffline
urn:xmpp:carbons:2
urn:xmpp:ping
urn:xmpp:sic:0
urn:xmpp:sic:1
urn:xmpp:time
vcard-temp

Identities

┌───────┬─────┬────────┐
│catego │ typ │ name   │
├┄┄┄┄┄┄┄┼┄┄┄┄┄┼┄┄┄┄┄┄┄┄┤
│pubsub │ pep │        │
│server │ im  │ Prosody│
└───────┴─────┴────────┘

Items

┌────────────────────────┬──┬─┐
│entity                  │  │ │
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┼┄┄┼┄┤
│chat.libervia.org       │  │ │
│proxy.libervia.org      │  │ │
│sat-pubsub.libervia.org │  │ │
│irc.libervia.org        │  │ │
│salut.libervia.org      │  │ │
│upload.libervia.org     │  │ │
└────────────────────────┴──┴─┘


Query an account

$ jp info disco test@example.org
Features

http://jabber.org/protocol/pubsub#publish
urn:xmpp:mam:0
urn:xmpp:mam:1
urn:xmpp:mam:2
urn:xmpp:push:0
urn:xmpp:sid:0

Identities

┌────────┬────────────┬─┐
│categor │ type       │ │
├┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┄┄┄┼┄┤
│pubsub  │ pep        │ │
│account │ registered │ │
└────────┴────────────┴─┘

Manage pubsub nodes

The following examples show how to manage pubsub nodes on the service pubsub.libervia.org .

Create a node

$ jp pubsub node create -s pubsub.libervia.org node_name

Subscribe to a node

$ jp pubsub subscribe -s pubsub.libervia.org node_name

Edit

The edit command allows to edit an item under a node.

$ jp pubsub edit -s pubsub.libervia.org node_name

The default text editor is opened. It is possible to directly edit a XML file. This command is useful for debugging purpose.

If you want to edit a post without having to edit xml directly, use jp blog edit.

As an example, you can try to edit the following xml file.

<source lang="xml"><entry xmlns="http://www.w3.org/2005/Atom">

 <author>
   <name>author@example.com</name>
 </author>
 <generator>JP (SàT)</generator>
 <title>I am a pubsub post !</title>
 <content>This is the content of this great post.</content>

</entry></source>


Manage your XMPP Blog

It is possible to manage a post with XMPP. It is based on PEP, a simplified version of pubsub. If your server support PEP, JP can help you to manage this blog easily.

Publish a post

First, you need to define your preferred syntax. In this example, I select markdown. This option can also be set in any other frontend (e.g. Primitivus). Whereafter you can edit a new post with the syntax jp blog edit.

$ jp param set Composition Syntax markdown -p sat
$ jp blog edit

Your favorite editor open and you can edit your blog post with markdown syntax. When you save and close it, another file open. You can edit your settings:

{
    "allow_comments": "true",
}

You can verify the accessibility of your post with the following command:

$ jp blog get 
content: 
Great test !
Make testing great again !
Yuuuuuuge publication.

It is also possible to modify your last blog post simply with jp blog edit --last-item.

Your blog post are also visible on other clients like Movim and interfaces like Livervia.

Use jp shell:

In order to ease debugging of services, JP comes with a shell interface. You only need to launch jp shell. You can obtain help by typing ?.

$ jp shell
cmd pubsub
pubsub> ?
Shell commands:
Documented commands (type help <topic>):
========================================
cmd    do    help  shell  use_clear  version
debug  exit  quit  use    verbose    whoami 

Action commands:
positional arguments:
  {get,delete,edit,subscribe,unsubscribe,subscriptions,node,affiliations,search,hook,uri}
    get                 get pubsub item(s)
    delete              delete an item
    edit                edit an existing or new pubsub item
    subscribe           subscribe to a node
    unsubscribe         unsubscribe from a node
    subscriptions       retrieve all subscriptions on a service
    node                node handling
    affiliations        retrieve all affiliations on a service
    search              search items corresponding to filters
    hook                trigger action on Pubsub notifications
    uri                 build URI

Select a command

> cmd pubsub
pubsub> use node urn:xmpp:microblog:0

Navigate into commands

> cmd bookmarks/list
bookmarks/list> -c
... CMD result
bookmarks/list> cmd ..
bookmarks> cmd
>

Example: List bookmarks

$  jp shell
> cmd bookmarks
bookmarks> cmd list
bookmarks/list> ?
Shell commands:
Documented commands (type help <topic>):
========================================
cmd    do    help  shell  use_clear  version
debug  exit  quit  use    verbose    whoami 

Action commands:
optional arguments:
  -h, --help            show this help message and exit
  -p PROFILE, --profile PROFILE
                        Use PROFILE profile key (default: @DEFAULT@)
  --pwd PASSWORD        Password used to connect profile, if necessary
  -c, --connect         Connect the profile before doing anything else
  -l {all,local,private,pubsub}, --location {all,local,private,pubsub}
                        storage location (default: all)
  -t {muc,url}, --type {muc,url}
                        bookmarks type (default: muc)
bookmarks/list> -t muc
private:
    Movim [movim@conference.movim.eu] (*)
    Archlinux - blah blah [archlinux-fr@chat.jabberfr.org]
    bot [bot@chat.libervia.org] (*)

Example: get disco information

> cmd info
info> use pubsub.libervia.org 
info> use pubsub.libervia.org 
info> disco
Features

http://jabber.org/protocol/disco#info
http://jabber.org/protocol/disco#items
http://jabber.org/protocol/pubsub
http://jabber.org/protocol/pubsub#create-nodes
http://jabber.org/protocol/pubsub#delete-items
http://jabber.org/protocol/pubsub#delete-nodes
http://jabber.org/protocol/pubsub#instant-nodes
http://jabber.org/protocol/pubsub#item-ids
http://jabber.org/protocol/pubsub#publish
http://jabber.org/protocol/pubsub#publisher-affiliation
http://jabber.org/protocol/pubsub#purge-nodes
http://jabber.org/protocol/pubsub#retract-items
http://jabber.org/protocol/pubsub#retrieve-items
http://jabber.org/protocol/pubsub#retrieve-subscriptions
http://jabber.org/protocol/pubsub#subscribe

Identities

┌───────┬─────────┬───────────────────────┐
│catego │ type    │ name                  │
├┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┤
│pubsub │ service │ Prosody PubSub Service│
└───────┴─────────┴───────────────────────┘