Nicer prints
This commit is contained in:
parent
eb9827bb33
commit
1333c03954
17
src/phicli
17
src/phicli
|
@ -19,7 +19,7 @@ def showuser(uid):
|
|||
print('User {} not found'.format(uid))
|
||||
return
|
||||
|
||||
print('\nuid: {}\n{}\n\n'.format(uid, pp(user)))
|
||||
print(pp(user))
|
||||
|
||||
|
||||
@cli.register('add a new user', ['user identifier'])
|
||||
|
@ -28,6 +28,11 @@ def adduser(uid):
|
|||
full_prompt = '{} [{}] '.format(prompt, default)
|
||||
return input(full_prompt) or default
|
||||
|
||||
user = get_user_by_uid(client, uid)
|
||||
if user is not None:
|
||||
print("User {} already existing".format(uid))
|
||||
return
|
||||
|
||||
cn = ask('Common name:', uid)
|
||||
sn = ask('Last name:', uid)
|
||||
mail = ask('Mail:', '{}@localhost'.format(uid))
|
||||
|
@ -42,7 +47,8 @@ def adduser(uid):
|
|||
|
||||
# Check
|
||||
user = get_user_by_uid(client, uid)
|
||||
print('\nuid: {}\n{}\n\n'.format(uid, pp(user)))
|
||||
print()
|
||||
print(pp(user))
|
||||
|
||||
|
||||
@cli.register('delete an user', ['user identifier'])
|
||||
|
@ -54,8 +60,8 @@ def deluser(uid):
|
|||
|
||||
user = get_user_by_uid(client, uid)
|
||||
if user is not None:
|
||||
print('Deleting')
|
||||
delete_user(client, user)
|
||||
print('Done')
|
||||
else:
|
||||
print('User {} not found'.format(uid))
|
||||
|
||||
|
@ -67,18 +73,15 @@ def showgroup(cn):
|
|||
print('Group {} not found'.format(gcn))
|
||||
return
|
||||
|
||||
print('\ncn: {}\n{}\n\n'.format(cn, pp(group)))
|
||||
|
||||
print(pp(group))
|
||||
|
||||
|
||||
@cli.register('list all groups')
|
||||
def listgroups():
|
||||
groups = get_all_groups(client)
|
||||
|
||||
print()
|
||||
for group in groups:
|
||||
print(group['cn'])
|
||||
print()
|
||||
|
||||
|
||||
@cli.register('add an user to a group',
|
||||
|
|
Loading…
Reference in New Issue
Block a user