Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Command line client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EOLE
Zéphir
Command line client
Commits
20c60a1a
Commit
20c60a1a
authored
5 years ago
by
Bruno Boiget
Committed by
Matthieu Lamalle
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add describe command to client
parent
aa1967ac
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
zephir-client
+24
-5
24 additions, 5 deletions
zephir-client
zephir_client.py
+17
-0
17 additions, 0 deletions
zephir_client.py
with
41 additions
and
5 deletions
zephir-client
+
24
−
5
View file @
20c60a1a
...
...
@@ -5,7 +5,7 @@ import yaml
import
sys
from
json
import
dumps
from
pathlib
import
Path
from
zephir_client
import
remote_json_to_config
,
cmdline_factory
,
send
,
remove_token
,
list_messages
,
authenticate
from
zephir_client
import
remote_json_to_config
,
cmdline_factory
,
send
,
remove_token
,
list_messages
,
describe_messages
,
authenticate
import
config
as
zconf
# get calling script base name
...
...
@@ -16,7 +16,7 @@ def main():
URL
=
zcliconf
.
url
VERSION
=
zcliconf
.
version
OUTPUT
=
'
yaml
'
list_msgs
=
False
list_msgs
=
0
prettyjson
=
2
if
'
--json
'
in
sys
.
argv
:
...
...
@@ -54,22 +54,38 @@ def main():
if
'
list
'
in
sys
.
argv
:
if
'
-h
'
in
sys
.
argv
or
'
--help
'
in
sys
.
argv
:
help
()
list_msgs
=
True
list_msgs
=
1
start
=
None
if
len
(
sys
.
argv
)
>
2
:
start
=
sys
.
argv
[
2
]
sys
.
argv
.
remove
(
start
)
sys
.
argv
.
remove
(
'
list
'
)
if
'
describe
'
in
sys
.
argv
:
if
'
-h
'
in
sys
.
argv
or
'
--help
'
in
sys
.
argv
:
help
()
list_msgs
=
2
start
=
None
if
len
(
sys
.
argv
)
>
2
:
start
=
sys
.
argv
[
2
]
sys
.
argv
.
remove
(
start
)
sys
.
argv
.
remove
(
'
describe
'
)
remote_config
=
remote_json_to_config
(
URL
,
VERSION
)
config
=
cmdline_factory
(
remote_config
)
if
list_msgs
:
messages
=
list_messages
(
config
,
start
)
if
list_msgs
==
1
:
messages
=
list_messages
(
config
,
start
)
elif
list_msgs
==
2
:
messages
=
describe_messages
(
config
,
start
)
if
not
messages
:
print
(
"
Aucun résultat.
"
)
elif
OUTPUT
==
"
yaml
"
:
print
(
"
\n
{}
"
.
format
(
yaml
.
dump
(
messages
,
default_flow_style
=
False
)))
print
(
"
\n
"
)
for
msg
in
messages
:
print
(
msg
)
print
(
"
\n
"
)
else
:
print
(
dumps
(
messages
,
indent
=
prettyjson
))
sys
.
exit
(
0
)
...
...
@@ -113,6 +129,9 @@ Client pour interroger un serveur Zéphir.
{
progname
}
list [recherche]
Liste les commandes disponibles commençant par <recherche>.
{
progname
}
describe [recherche]
Décrit les commandes disponibles commençant par <recherche>.
{
progname
}
commande [paramètres]
Exécute le message avec ses paramètres.
...
...
This diff is collapsed.
Click to expand it.
zephir_client.py
+
17
−
0
View file @
20c60a1a
...
...
@@ -43,6 +43,23 @@ def list_messages(config, start=None):
else
:
return
messages
def
describe_messages
(
config
,
start
=
None
):
"""
Describes all available messages from config
"""
messages
=
config
.
option
(
'
message
'
).
value
.
list
()
descr
=
[]
for
msg
in
messages
:
# activate each message to enable matching options
config
.
option
(
'
message
'
).
value
.
set
(
msg
)
# retrieve message doc in matching optiondescription
try
:
doc
=
list
(
config
.
option
.
list
(
type
=
'
all
'
))[
1
].
option
.
doc
()
except
:
doc
=
'
!No description available!
'
if
start
is
None
or
msg
.
startswith
(
start
):
descr
.
append
(
f
"
{
msg
}
\n
{
doc
}
"
)
return
descr
def
send
(
url
,
version
,
config
):
# check authentication
# retrieve new message value
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment