Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
105
Merge Requests
105
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
10c95fcb
Commit
10c95fcb
authored
Mar 07, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapconsole: Use readline for completion and history
parent
573390ee
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletion
+23
-1
slapos/client.py
slapos/client.py
+23
-1
No files found.
slapos/client.py
View file @
10c95fcb
...
...
@@ -35,6 +35,7 @@ import os
from
slapos.slap
import
ResourceNotReady
import
slapos.slap.slap
import
sys
import
atexit
class
Parser
(
OptionParser
):
"""
...
...
@@ -292,6 +293,27 @@ examples :
>>> # Fetch instance informations on already launched instance
>>> request(kvm, "myuniquekvm").getConnectionParameter("url")"""
%
sys
.
argv
[
0
]
config
=
Config
(
*
Parser
(
usage
=
usage
).
check_args
())
local
=
init
(
config
)
# try to enable readline with completion and history
try
:
import
readline
except
ImportError
:
pass
else
:
try
:
import
rlcompleter
readline
.
set_completer
(
rlcompleter
.
Completer
(
local
).
complete
)
except
ImportError
:
pass
readline
.
parse_and_bind
(
"tab: complete"
)
historyPath
=
os
.
path
.
expanduser
(
"~/.slapconsolehistory"
)
def
save_history
(
historyPath
=
historyPath
):
readline
.
write_history_file
(
historyPath
)
if
os
.
path
.
exists
(
historyPath
):
readline
.
read_history_file
(
historyPath
)
atexit
.
register
(
save_history
)
__import__
(
"code"
).
interact
(
banner
=
""
,
local
=
local
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment