Commit 10ee8be9 authored by Daniel STAN's avatar Daniel STAN

draft de mode interactif

parent 81f095d8
......@@ -27,6 +27,7 @@ import copy
import glob
import ConfigParser
import shlex
import cmd
# Import de la config
def get_config_path():
......@@ -934,6 +935,42 @@ def parse_roles(options, cast=False):
return list(ret)
class CpasswordClient(cmd.Cmd, object):
_cached_list = None
def __init__(self, options):
super(CpasswordClient, self).__init__()
self.options = options
def do_EOF(self, line):
return True
def do_view(self, line):
options.fname = line
def _list(self):
if self._cached_list is not None:
return self._cached_list
self._cached_list = []
my_roles, _ = get_my_roles(self.options)
files = all_files(self.options)
keys = files.keys()
for fname in keys:
froles = files[fname]
access = set(my_roles).intersection(froles) != set([])
if access:
def complete_view(self, text, line, begidx, endidx):
return [s for s in self._list() if s.startswith(text)]
def interactive(options):
def insult_on_nofilename(options, parser):
"""Insulte (si non quiet) et quitte si aucun nom de fichier n'a été fourni en commandline."""
if options.fname == None:
......@@ -987,6 +1024,9 @@ if __name__ == "__main__":
action_grp.add_argument('--list-servers', action='store_const', dest='action',
default=show_file, const=show_servers,
help="Lister les serveurs")
action_grp.add_argument('-i', '--interactive', action='store_const', dest='action',
default=show_file, const=interactive,
help="Mode interactif")
action_grp.add_argument('--recrypt-files', action='store_const', dest='action',
default=show_file, const=recrypt_files,
help="""Rechiffrer les mots de passe.
......@@ -1046,3 +1086,4 @@ if __name__ == "__main__":
# On exécute l'action demandée
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment