diff options
author | Ruben Pollan <meskio@sindominio.net> | 2016-05-19 13:14:56 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2016-05-19 13:14:56 +0200 |
commit | 7ba3e07b4659de38a189798540fe5e80b66b10d0 (patch) | |
tree | 4fd633b114556983c3784daca81b6191030ecce3 | |
parent | 13963904a184834a6a2a20c9a6d59c5ad6ec37ff (diff) |
[feat] ask for password only if needed
Not all the user commands need to ask for the password.
-rwxr-xr-x | src/leap/bitmask/cli/bitmask_cli.py | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/src/leap/bitmask/cli/bitmask_cli.py b/src/leap/bitmask/cli/bitmask_cli.py index 126577f5..5be6e9fc 100755 --- a/src/leap/bitmask/cli/bitmask_cli.py +++ b/src/leap/bitmask/cli/bitmask_cli.py @@ -228,35 +228,41 @@ def send_command(cli): data = ('stats',) elif cmd == 'user': - username = subargs.username - if username and '@' not in username: - error("Username ID must be in the form <user@example.org>", + if 1 != (subargs.active + subargs.create + + subargs.authenticate + subargs.logout): + error('Use bitmask_cli user --help to see available subcommands', stop=True) return - if not username: - username = '' - # TODO check that ONLY ONE FLAG is True - # TODO check that AT LEAST ONE FLAG is True - - passwd = getpass.getpass() data = ['user'] if subargs.active: data += ['active', '', ''] - elif subargs.create: - data += ['signup', username, passwd] - - elif subargs.authenticate: - data += ['authenticate', username, passwd] - - elif subargs.logout: - data += ['logout', username] - else: - error('Use bitmask_cli user --help to see available subcommands') - return + if subargs.create: + data.append('signup') + elif subargs.authenticate: + data.append('authenticate') + elif subargs.logout: + data.append('logout') + + username = subargs.username + if username and '@' not in username: + error("Username ID must be in the form <user@example.org>", + stop=True) + return + if not subargs.logout and not username: + error("Missing username ID but needed for this command", + stop=True) + return + elif not username: + username = '' + data.append(username) + + if not subargs.logout: + passwd = getpass.getpass() + data.append(passwd) elif cmd == 'mail': data = ['mail'] |