Compare commits

...

1 Commits

Author SHA1 Message Date
30b2757257 started working on the cli 2019-04-19 18:40:07 +02:00
3 changed files with 39 additions and 0 deletions

0
bunker/cli/__init__.py Normal file
View File

17
bunker/cli/io.py Normal file
View File

@ -0,0 +1,17 @@
import os
from getpass import getpass
from ..bunker import Bunker
def open(file_name, create):
if(not os.path.exists(file_name)):
if(not create):
raise IOError("file '{}' does not exist".format(file_name))
else:
if(not os.path.isfile(file_name)):
raise IOError("'{}' is not a file".format(file_name))
return Bunker.open(file_name)
def read_password():
getpass()

22
bunker/cli/methods.py Normal file
View File

@ -0,0 +1,22 @@
from .io import read_password
from ..backends.directory_store import DirectoryStore
from ..backends.kvs import KeyValueStore
def add_kvs(bunker, name, password):
if(password is None):
password = read_password()
bunker.add_component(KeyValueStore.component_type, name, password)
def add_ds(bunker, name, password):
if(password is None):
password = read_password()
bunker.add_component(DirectoryStore.component_type, name, password)
def list_components(bunker, password):
if(password is None):
password = read_password()
for row in bunker._components:
print(row["type"], ",\t", row["component"])